setVisibility(GONE) view becomes invisible but still occupies space

后端 未结 13 1965
我在风中等你
我在风中等你 2020-12-03 03:56

I\'ve got a view that is effectively is a button. Here is its XML layout (add_new.xml)




        
13条回答
  •  醉梦人生
    2020-12-03 04:48

    A generic and easy solution is to avoid all thuse heck of code:

    You need to add a Container Layout or a Parent Layout over your set of views that you want to hide. It can be anything like CardView or FrameLayout or etc.

    Just it has to be a parent for that view that you want to hide. And you wont get all those white spaces. Coz it will consider the entire container to hide instead of considering individual views to HIDE thus, avoiding the white spaces.

提交回复
热议问题