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
<LinearLayout android:id="@+id/ll_1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <ImageView android:id="@+id/iv1" android:src="@drawable/ic_launcher" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="invisible"/> <ImageView android:id="@+id/iv2" android:src="@drawable/ic_launcher" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="visible"/> </LinearLayout> <LinearLayout android:id="@+id/ll_2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <ImageView android:id="@+id/iv3" android:src="@drawable/ic_launcher" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone"/> <ImageView android:id="@+id/iv4" android:src="@drawable/ic_launcher" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="visible"/> </LinearLayout>
通过上面的代码可以看到像右侧的效果:
posted on 2014-03-13 14:33 jinfenglee 阅读(399) 评论(0) 编辑 收藏 举报