"invisible" : 不可见

"gone"      : 隐   藏

主要区别在于控件设置了invisible后控件不可见,但是保留了控件在界面上的空间,而设置为gone,则不保留控件占有的空间。

test.xml

01.<?xml
version=
"1.0" encoding="utf-8"?>
02.<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
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"?>
02.<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
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"?>
02.<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
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的区别的更多相关文章

  1. Android控件属性大全(转)

    http://blog.csdn.net/pku_android/article/details/7365685 LinearLayout         线性布局        子元素任意: Tab ...

  2. Android控件属性大全[整理转载]

    控件属性: android属性 Android功能强大,界面华丽,但是众多的布局属性就害苦了开发者,下面这篇文章结合了网上不少资料, 第一类:属性值为true或falseandroid:layout_ ...

  3. 【转载】Android控件属性大全

    控件属性: android属性 Android功能强大,界面华丽,但是众多的布局属性就害苦了开发者,下面这篇文章结合了网上不少资料, 第一类:属性值为true或falseandroid:layout_ ...

  4. 转:Android控件属性

    Android功能强大,界面华丽,但是众多的布局属性就害苦了开发者,下面这篇文章结合了网上不少资料,花费本人一个下午搞出来的,希望对其他人有用. 第一类:属性值为true或false android: ...

  5. Android 控件属性

    TextView 文字属性//文字左右居中android:layout_centerHorizontal="true"//文字垂直居中android:layout_centerVe ...

  6. Android控件显示和隐藏

    Android控件都有visibility属性,该属性有三个可能值:visible.invisible.gone.可以通过预设或是Java程序控制这些控件的显示或隐藏. 一.在XML配置文件设置 可见 ...

  7. Android 控件架构及View、ViewGroup的测量

    附录:示例代码地址 控件在Android开发的过程中是必不可少的,无论是我们在使用系统控件还是自定义的控件.下面我们将讲解一下Android的控件架构,以及如何实现自定义控件. 1.Android控件 ...

  8. Android群英传笔记——第三章:Android控件架构与自定义控件讲解

    Android群英传笔记--第三章:Android控件架构与自定义控件讲解 真的很久没有更新博客了,三四天了吧,搬家干嘛的,心累,事件又很紧,抽时间把第三章大致的看完了,当然,我还是有一点View的基 ...

  9. Android控件常见属性

    1.宽/高android:layout_width android:layout_height// 取值match_parent //匹配父控件wrap_content //自适应,根据内容 如果指定 ...

随机推荐

  1. svn数据仓库配置,权限配置

    svn服务的开启有两种方式, ·        自带的svnserve服务(访问地址类似于svn://192.168.80.18/repos/) ·        与Apache配合使用  (访问地址 ...

  2. 使用shell操作HDFS

    前提是都已经配置好了,可以参考hadoop伪分布安装:http://blog.csdn.net/jerome_s/article/details/25788967 linux的文件系统与hdfs的关系 ...

  3. 找不到BufferedImage这个Class的解决方法

    找不到BufferedImage这个Class的解决方法 环境: [1]RedHat AS5 64位      [2]WebSphere6.0 32位版本 正文:    发现原来在RedHat AS4 ...

  4. 【NPR】非真实感渲染实验室

    写在前面 前几天在知乎看到一个问题--关于非实感图形学或者风格化渲染有哪些好的书或者paper,我刚好接触过一些就去里面回答了一下.答完以后突然想在Unity里搞一个这样的集锦,把一些简单的NPR论文 ...

  5. Swift的print不换行打印的方法

    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢! hopy ;) swift大多数情况下我们直接用默认的print函数打印就可以 ...

  6. Spring入门介绍(一)

    Spring是一个轻量级控制反转(IOC)和面向切面(AOP)的容器框架,它主要是为了解决企业应用开发的复杂性而诞生的. 目的:解决企业应用开发的复杂性. 功能:使用基本的javaBean代替EJB. ...

  7. 菜鸟学习物联网---辨析基于Andriod 5.1,Linux,Windows10开发Dragon Board 410c板

    点击打开链接 诸位亲最近怎么样?刚过完年上班是不是很不情愿?自古做事者,不唯有坚韧不拔之志,亦或有超世之才.所以,诸位好好加油.今天小编想给大家系统性总结一下Dragon Board 410c板基于A ...

  8. 自定义AlertDialog(仿微信)

    安卓自定义AlertDialog,原理很简单: AlertDialog dialog = new AlertDialog.Builder(MainActivity.this).create(); di ...

  9. 5.0、Android Studio调试你的应用

    Android Studio包含了一个调试器,允许你调试运行在Android虚拟机或连接的Android设备的应用.通过Android Studio的调试器,你可以: 1. 选择你调试设备的app 2 ...

  10. 因 URL 意外地以“/HelloWorld”结束,请求格式无法识别

    http://www.cnblogs.com/AngelLee2009/p/3540527.html