Reputation: 397
I have the next problem. Server send me a response and depends from this response my screen have or does not have some layout.For example :if server return 0, I need to remove my LinearLayout but_status_group. I removed layout, but on this place I have a free space, how can I up to the top layouts and view, that stayed before but_status_group?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/operation_additional_data">
<TextView
android:id="@+id/status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textSize="22sp"
android:textColor="@color/red"
android:layout_marginTop="10dp" />
<TextView
android:id="@+id/status_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/status"
android:gravity="center_horizontal"
android:textSize="22sp" />
<LinearLayout
android:id="@+id/but_status_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2"
android:layout_below="@id/status_description"
android:layout_marginTop="5dp"
android:visibility="invisible">
<Button
android:id="@+id/but_confirm"
android:text="@string/confirm_but"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="10dp"
android:visibility="visible" />
<Button
android:id="@+id/but_generate_code"
android:text="@string/take_new_code"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="visible" />
</LinearLayout>
<TextView
android:id="@+id/amount"
android:layout_marginTop="5dp"
android:layout_below="@id/but_status_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textColor="@color/reference"
android:textSize="22sp" />
<LinearLayout
android:id="@+id/operation_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@+id/amount"
android:orientation="vertical"
android:weightSum="2">
<TextView
android:id="@+id/operation_creation_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_weight="1"
android:textSize="22sp" />
<TextView
android:id="@+id/operation_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:textSize="22sp" />
</LinearLayout>
<TextView
android:id="@+id/operation_details_header"
android:text="@string/payment_details_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/operation_info"
android:layout_marginTop="5dp"
android:textSize="22sp"
android:textStyle="bold" />
<TextView
android:id="@+id/operation_details"
android:layout_below="@id/operation_details_header"
android:layout_marginLeft="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="22sp" />
</RelativeLayout>
Upvotes: 0
Views: 82
Reputation: 28823
If you make the layout using
myLayout.setVisibility(View.INVISIBLE);
you will get that blank space.
Remove it using
myLayout.setVisibility(View.GONE);
So that space will be covered by next layout. Refer this
Hope this helps.
Upvotes: 1
Reputation: 3513
My Experience:I think It is better if you make different layout file for different type of view as It will be lot easier to maintain the code.If requirement varies your code may be broke down.It is lot easier to change the code when requirement changes.
Upvotes: 0
Reputation: 1321
remove the parent layout Linear Layout to Relative layout and maintain dependency for it.
Upvotes: 0