2

I am using the LinearLayout and inside there's button I am making visibilty gone based on supported states. SupportedStatuses are true then making Button as Visible but SupprtedStatuse are false then making button as Gone.

This is in a header and Button is Gone but still takes up the space. Here is the Layout which I am using.

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

Anybody have a good solution then it helps me a lot.

Swift
  • 829
  • 2
  • 12
  • 33

2 Answers2

1

You could use a FrameLayout around whatever layout you are using For example:

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

    <!-- put your views here -->
</FrameLayout>

This will ensure when using View.GONE the FrameLayout collapses on the space.

Peter Hall
  • 53,120
  • 14
  • 139
  • 204
Dhruv Verma
  • 420
  • 5
  • 13
-1

Try to wrap your button in another Linear/Frame layout and change their visibility as well.

Sagi Mymon
  • 958
  • 9
  • 12