Android控件属性android:visibility的invisible与gone的区别
"invisible" : 不可见
"gone" : 隐 藏
主要区别在于控件设置了invisible后控件不可见,但是保留了控件在界面上的空间,而设置为gone,则不保留控件占有的空间。
test.xml
01.
<?xml
version=
"1.0"
encoding=
"utf-8"
?>
03.
android:layout_width=
"match_parent"
04.
android:layout_height=
"match_parent"
05.
android:orientation=
"horizontal"
>
06.
07.
<TextView
08.
android:layout_width=
"match_parent"
09.
android:layout_height=
"100dip"
10.
android:layout_weight=
"1"
11.
android:background=
"@color/green"
/>
12.
13.
<TextView
14.
android:layout_width=
"match_parent"
15.
android:layout_height=
"100dip"
16.
android:layout_weight=
"1"
17.
android:background=
"@color/red"
/>
18.
19.
</LinearLayout>
效果:
invisible.xml
01.
<?xml
version=
"1.0"
encoding=
"utf-8"
?>
03.
android:layout_width=
"match_parent"
04.
android:layout_height=
"match_parent"
05.
android:orientation=
"horizontal"
>
06.
07.
<TextView
08.
android:layout_width=
"match_parent"
09.
android:layout_height=
"100dip"
10.
android:layout_weight=
"1"
11.
android:background=
"@color/green"
/>
12.
13.
<TextView
14.
android:layout_width=
"match_parent"
15.
android:layout_height=
"100dip"
16.
android:layout_weight=
"1"
17.
android:background=
"@color/red"
18.
android:visibility=
"invisible"
/>
19.
20.
</LinearLayout>
效果:
gone.xml
01.
<?xml
version=
"1.0"
encoding=
"utf-8"
?>
03.
android:layout_width=
"match_parent"
04.
android:layout_height=
"match_parent"
05.
android:orientation=
"horizontal"
>
06.
07.
<TextView
08.
android:layout_width=
"match_parent"
09.
android:layout_height=
"100dip"
10.
android:layout_weight=
"1"
11.
android:background=
"@color/green"
/>
12.
13.
<TextView
14.
android:layout_width=
"match_parent"
15.
android:layout_height=
"100dip"
16.
android:layout_weight=
"1"
17.
android:background=
"@color/red"
18.
android:visibility=
"gone"
/>
19.
20.
</LinearLayout>
效果:
从这三种效果,invisible和gone的区别就一目了然了。
Android控件属性android:visibility的invisible与gone的区别的更多相关文章
- Android控件属性大全(转)
http://blog.csdn.net/pku_android/article/details/7365685 LinearLayout 线性布局 子元素任意: Tab ...
- Android控件属性大全[整理转载]
控件属性: android属性 Android功能强大,界面华丽,但是众多的布局属性就害苦了开发者,下面这篇文章结合了网上不少资料, 第一类:属性值为true或falseandroid:layout_ ...
- 【转载】Android控件属性大全
控件属性: android属性 Android功能强大,界面华丽,但是众多的布局属性就害苦了开发者,下面这篇文章结合了网上不少资料, 第一类:属性值为true或falseandroid:layout_ ...
- 转:Android控件属性
Android功能强大,界面华丽,但是众多的布局属性就害苦了开发者,下面这篇文章结合了网上不少资料,花费本人一个下午搞出来的,希望对其他人有用. 第一类:属性值为true或false android: ...
- Android 控件属性
TextView 文字属性//文字左右居中android:layout_centerHorizontal="true"//文字垂直居中android:layout_centerVe ...
- Android控件显示和隐藏
Android控件都有visibility属性,该属性有三个可能值:visible.invisible.gone.可以通过预设或是Java程序控制这些控件的显示或隐藏. 一.在XML配置文件设置 可见 ...
- Android 控件架构及View、ViewGroup的测量
附录:示例代码地址 控件在Android开发的过程中是必不可少的,无论是我们在使用系统控件还是自定义的控件.下面我们将讲解一下Android的控件架构,以及如何实现自定义控件. 1.Android控件 ...
- Android群英传笔记——第三章:Android控件架构与自定义控件讲解
Android群英传笔记--第三章:Android控件架构与自定义控件讲解 真的很久没有更新博客了,三四天了吧,搬家干嘛的,心累,事件又很紧,抽时间把第三章大致的看完了,当然,我还是有一点View的基 ...
- Android控件常见属性
1.宽/高android:layout_width android:layout_height// 取值match_parent //匹配父控件wrap_content //自适应,根据内容 如果指定 ...
随机推荐
- iOS学习笔记--Quartz2D
Quartz 2D是一个二维绘图引擎,同时支持iOS和Mac系统. Quartz 2D能完成的工作: 1. 绘制图形 : 线条\三角形\矩形\圆\弧等 2. 绘制文字 3. 绘制\生成图片(图像) 4 ...
- springMVC源码分析--ControllerBeanNameHandlerMapping(八)
在上一篇博客springMVC源码分析--AbstractControllerUrlHandlerMapping(六)中我们介绍到AbstractControllerUrlHandlerMapping ...
- argparse库 学习记录
初始化 始见参数 name or flags action nargs default type choices required help dest metavar 总结 继上次的optparser ...
- Compass实战 站内搜索
今天早上打算对这两天学习的Lucene以及Compass总结一下,想来想去,还是写个小项目来验证最好了.于是就有了今天的这篇文章.难易程度适合对于Compass或者Lucene刚入门的童鞋,大牛看到后 ...
- Python Generator 运行细节验证
今天来__next__和send, 改天来throw和close class A: def __setattr__(self, key, val): print('set %s to %s'%(key ...
- Android学习路线指南
看到这位大牛的博文,不禁得感概,我最近也遇到了很多问题,内心彷徨不堪,转载大牛这篇博文,是为了更好的勉励自己.原文地址在最后面. 前言 看到一篇文章中提到"最近几年国内的初级Android程 ...
- Linux内核分配内存的方式
page = alloc_pages(GFP_KERNEL, get_order(1234));分配失败返回NULLGFP_KERNEL ---> 分配标志,当没有足够内存分配时,睡眠阻塞,直 ...
- Java数据类型及类型转换
http://blog.csdn.net/pipisorry/article/details/51290064 java浮点数保留n位小数 import java.text.DecimalFormat ...
- UNIX网络编程——套接字选项(SO_RCVBUF和SO_SNDBUF)
有时候我们需要控制套接字的行为(如修改缓冲区的大小),这个时候我们就要学习套接字选项. int getsockopt(int sockfd,int level,int optname,void *op ...
- UNIX环境高级编程——网络编程常用函数及结构
IP地址的转换 #include <arpa/inet.h> int inet_aton(const char *strptr, struct i ...