问题
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.
回答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.
回答2:
Try to wrap your button in another Linear/Frame layout and change their visibility as well.
来源:https://stackoverflow.com/questions/30367587/visibility-of-gone-takes-still-space-of-particular-control-in-android