How to play a layout component up? [duplicate]

1

Good afternoon I'm doing an app for studies, and I'm encountering a little problem is not a bug, but come on, this is my home screen:

As it is in the print below, I have a relative layout that has 1 note with its edittext and weight with its edittext.

When I click on the + one that is an Imagebutton it will enter the setonclicklistnner and visible arrow to another relative layout that is just below ...

Inthispartthatiscircledinredisanotherelementthatisinsidearelativelayoutthathasitsownid,inthatxitinvisiblearrowpronote2,gettingasitwasinimagetwo...

Nowafterexplaining,myquestionishowdoIgetthatblankpartwheretheotherrelativesomalayoutlies?asiftherewasnothingthere,andthattheresultandthesumareclosetonote1?

Mylayoutcodeisthis:

<?xmlversion="1.0" encoding="utf-8"?>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:text="Nome da Matéria:"
        android:textSize="16dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</RelativeLayout>


<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">


    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textPersonName"
        android:text="Name"
        android:ems="10"
        android:id="@+id/editText2" />

</RelativeLayout>

<RelativeLayout
    android:layout_marginTop="10dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:text="Nota 1:"
        android:textSize="18dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView2"


        android:textAllCaps="false" />

    <TextView

        android:text="Peso"
        android:layout_marginLeft="120dp"
        android:textSize="18dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:id="@+id/textView3" />


</RelativeLayout>


<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">


    <EditText
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:inputType="numberDecimal"
        android:text=""
        android:ems="10"
        android:id="@+id/editText3"
       />

    <EditText

        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:inputType="numberDecimal"
        android:text=""
        android:ems="10"
        android:id="@+id/editText"
        android:fontFamily="sans-serif"
        android:layout_marginLeft="120dp"
         />

 <ImageButton
     android:layout_width="wrap_content"
     android:background="#fff"
     android:layout_marginLeft="220dp"
     android:src="@drawable/plus_one"
     android:id="@+id/more1"
     android:layout_height="wrap_content" />


</RelativeLayout>


<RelativeLayout
    android:visibility="invisible"
    android:id="@+id/lig1"
    android:layout_marginTop="10dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:text="Nota 2:"
        android:textSize="18dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAllCaps="false" />

    <TextView

        android:text="Peso"
        android:layout_marginLeft="120dp"
        android:textSize="18dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />


</RelativeLayout>



<RelativeLayout
    android:visibility="invisible"
    android:id="@+id/lig1.1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">


    <EditText
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:inputType="numberDecimal"
        android:text=""
        android:ems="10"
        android:id="@+id/editText4"
        />

    <EditText

        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:inputType="numberDecimal"
        android:text=""
        android:ems="10"
        android:id="@+id/editText5"
        android:fontFamily="sans-serif"
        android:layout_marginLeft="120dp"
        />

        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/closerlig1"
            android:background="#fff"
            android:layout_marginLeft="220dp"
            android:src="@drawable/close_box_outline"
            />


</RelativeLayout>


<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <TextView
        android:text="TextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView4"
        android:textSize="20sp" />

    <Button
        android:text="Somar"
        android:layout_alignParentRight="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/resultado"
        android:textAllCaps="false" />

</RelativeLayout>

    
asked by anonymous 04.01.2017 / 16:57

1 answer

3

Rogers,

You need to understand the difference between invisible and gone .

If you use android:visibility="invisible" , the layout will remain there, but invisible, so its space continues.

Now if you use android:visibility="gone" the layout will remove that part from there, even taking up white space.

Example in java:

id_do_seu_layout.setVisibility(View.GONE);

and to make it appear again in the layout:

id_do_seu_layout.setVisibility(View.VISIBLE);
    
04.01.2017 / 17:05