Why does a LinearLayout which is invisible take up space?

后端 未结 4 792
心在旅途
心在旅途 2021-02-05 09:10

I\'ve got the following LinearLayout...



        
4条回答
  •  执笔经年
    2021-02-05 09:47

    The documentation of Invisible says:

    This view is invisible, but it still takes up space for layout purposes.

    So setting the visibility of layout to invisible just hides the layout, but does not free the consumed space. If you want to do that you have to set the visibility to gone.

    Gone does what you want:

    This view is invisible, and it doesn't take any space for layout purposes.

    See also: http://developer.android.com/reference/android/view/View.html#setVisibility(int)

提交回复
热议问题