Visibility of Gone takes still space of particular control in android?

倾然丶 夕夏残阳落幕 提交于 2019-12-24 15:16:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!