Visibility属性中invisible和gone 区别

http://developer.android.com/reference/android/view/View.html#attr_android:visibility

下面是Android Developers上面介绍它们的区别:

android:visibility

Controls the initial visibility of the view.

Must be one of the following constant values.

Constant Value Description
visible 0 Visible on screen; the default value.
invisible 1 Not displayed, but taken into account during layout (space is left for it).
gone 2 Completely hidden, as if the view had not been added.

This corresponds to the global attribute resource symbol visibility.

Related Methods
  • setVisibility(int)



gone就是彻底隐藏,InVisible就是看不见,但是控件对空间的占用仍然是存在的。



    
      
     
     
    
      
      

通过上面的代码可以看到像右侧的效果:


你可能感兴趣的:(android,UI)