"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. JVM内存区域划分(JDK6/7/8中的变化)

    前言 Java程序的运行是通过Java虚拟机来实现的.通过类加载器将class字节码文件加载进JVM,然后根据预定的规则执行.Java虚拟机在执行Java程序的过程中会把它所管理的内存划分为若干个不同 ...

  2. SQLite Insert 语句(http://www.w3cschool.cc/sqlite/sqlite-insert.html)

    SQLite Insert 语句 SQLite 的 INSERT INTO 语句用于向数据库的某个表中添加新的数据行. 语法 INSERT INTO 语句有两种基本语法,如下所示: INSERT IN ...

  3. 修改Chrome默认的搜索引擎

    Chrome浏览器可谓是现在世界上最受欢迎的一款浏览器了,不仅仅是在其简单易用还有优雅的界面,还有与一众以人为本的设计理念,在我的眼里,匠心独具.但是咧,由于在国内谷歌是被禁止访问的,所以Chrome ...

  4. Android:Field can be converted to a local varible.

    背景 使用 Android Studio 开发 Android 有一段时间了,偶尔会碰到 AS 在一些私有变量上有黄色高亮提示Field can be converted to a local var ...

  5. iOS下WebRTC音视频通话(二)-局域网内音视频通话

    这里是iOS 下WebRTC音视频通话开发的第二篇,在这一篇会利用一个局域网内音视频通话的例子介绍WebRTC中常用的API. 如果你下载并编译完成之后,会看到一个iOS 版的WebRTC Demo. ...

  6. springMVC源码分析--容器初始化(一)ContextLoaderListener

    在spring Web中,需要初始化IOC容器,用于存放我们注入的各种对象.当tomcat启动时首先会初始化一个web对应的IOC容器,用于初始化和注入各种我们在web运行过程中需要的对象.当tomc ...

  7. 偏置方差分解Bias-variance Decomposition

    http://blog.csdn.net/pipisorry/article/details/50638749 偏置-方差分解(Bias-Variance Decomposition) 偏置-方差分解 ...

  8. (国内)完美下载android源代码(文章已经丢失)

    刚刚文章莫名其妙的丢了,我重写了一篇,http://blog.csdn.net/song19891121/article/details/50099857 我们在很多时候需要下载android源代码进 ...

  9. ntoskrnl符号在IDA中查看的问题

    最近发现x64的ntoskrnl.exe,如果直接在IDA中查看,会有一些函数IDA没有识别出来,比如

  10. OpenCL异构计算资料收集

    Easy OpenCL with Python   原文  http://www.drdobbs.com/open-source/easy-opencl-with-python/240162614   ...