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 //自适应,根据内容 如果指定 ...
随机推荐
- 协议系列之IP协议
1.协议 协议(protocol)的定义:为计算机网络中进行数据交换而建立的规则.标准或约定的集合.两个终端相互通信时双方达成的一种约定,规定了一套通信规则,双方通信必须遵守这些规则.这些规则规定了分 ...
- javascript命名规则
javascript对大小写敏感(关键字.函数名.变量名等),标识符的首字符必须是字母.下划线或者$符,其后的字符可以含数字 如果之声明了变量,并未对其赋值,默认为undefined javascri ...
- EBS HRMS数据表
4.1. 人员基本息 表 (PER_ALL_PEOPLE_F) ...
- Struts2配置问题终极解决方案
从下午忙到现在,终于找到问题的根源了.写下此文,与君共勉. 我的目录结构是这样的. 关于配置文件加载问题 控制台下面报错,提示错误信息如下: 严重: Exception starting filter ...
- python 远程调度进程服务与客户端
python 远程调度进程服务与客户端 核心思想: 在本地或远程机器上创建一个进程,提供调度服务.使用了 APScheduler. 安装:APScheduler $ wget https://pypi ...
- 安卓IPC机制之Binder详解
IPC(Inter-Process Communication,跨进程通信)是指两个进程之间数据交换的过程,因此我们首先必须了解什么是进程,什么是线程. 进程:进程是正在运行的程序的实例,与程序相比, ...
- Dynamics CRM 2015 站点地图公告配置实体显示名称的变更
CRM更新2015后,在设置里找不到公告配置了 在原来的位置上你会东西一个叫活动源配置的东西,点开看后就是原来的公告配置.
- 可视化分析工具Cytoscape使用记录
最近项目要使用到可视化分析工具Cytoscape,所以会花费很多的时间跟精力来整理Cytoscape软件使用和开发的相关资料,希望写下的文章能减少有兴趣的同行学习跟开发所走的弯路时间.同时也是因为百度 ...
- iOS开发基础block的形式讲解
前几个星期,我利用通知写了一个仿京东选择地址的Demo(http://blog.csdn.net/hbblzjy/article/details/52212879),后来看过一篇文章说,尽量少用通知, ...
- Android进阶(九)APP编程感想
从初识Android到现在,在不断做APP(二维码.条形码扫描,彩票购买,火车票余票查询)的过程中,自己学会了很多东西.找时间整理了一下,总结如下: 其中,对于前两个APP,自己都是在他人已完成的基础 ...