How to reconstruct the XML of a Fragment layout, when it is expanded?

1

I have a screen with a fragment, which without being expanded, it just shows the username and password field and the button to register, and I wanted it when I expanded it, fields like name, date of birth, municipality, state, were inserted between the password field and the register button, remembering that it expands when the user is included in the user field.

Fragment XML looks like this:

<?xml version="1.0" encoding="utf-8"?>

<ScrollView android:id="@+id/login_form" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout android:id="@+id/email_novo_form" android:layout_width="match_parent"
        android:layout_height="wrap_content" android:orientation="vertical">

        <android.support.design.widget.TextInputLayout android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <EditText android:id="@+id/campoEmailNovoUsuario" android:layout_width="match_parent"
                android:layout_height="wrap_content" android:hint="@string/prompt_email"
                android:inputType="textEmailAddress" android:maxLines="1"
                android:singleLine="true" />

        </android.support.design.widget.TextInputLayout>

        <android.support.design.widget.TextInputLayout android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content" android:hint="@string/prompt_password"
                android:imeActionId="@+id/login"
                android:imeActionLabel="@string/action_sign_in_short"
                android:imeOptions="actionUnspecified" android:inputType="textPassword"
                android:maxLines="1" android:singleLine="true"
                android:id="@+id/campoSenhaNovo" />

        </android.support.design.widget.TextInputLayout>

        <CheckBox
            android:id="@+id/chk_mostrar_senha"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="@string/chk_mostrar_senha"/>

        <TextView
            android:id="@+id/texto_termos_criar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:textAlignment="center"/>

        <Button android:id="@+id/email_criar_button" style="?android:textAppearanceSmall"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:layout_marginTop="5dp" android:text="@string/acao_nova_conta"
            android:textStyle="bold"
            android:textColor="@color/branco"
            android:background="@drawable/botao_arredondado"
            android:gravity="center_horizontal|center_vertical"
            android:layout_gravity="center_horizontal" />

    </LinearLayout>
</ScrollView>

That's all.

    
asked by anonymous 09.11.2015 / 19:22

1 answer

1

In activity add a FrameLayout where the fragment

.....
.....
<FrameLayout 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/fragment_placeholder">
</FrameLayout>  
.....
.....

When you want to "expand" the fragment run the following code:

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.fragment_placeholder, new Sua_Classe_Fragment());
    ft.commit();
    
09.11.2015 / 20:47