"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. 《Shazam It! Music Recognition Algorithms, Fingerprinting, and Processing》译文

    最近看到一篇老外写的博客,简单介绍了shazam的工作原理.图非常好,所以就把它翻译成中文,希望对搞听歌识曲的人有帮助. 你可能遇到这样的场景:在酒吧或者餐厅听到你非常熟悉的歌,也许你曾经听过无数次, ...

  2. 20 ViewPager Demo4自动轮播

    MainActivity.java 思想:才用非常大的数 让其看起来可以循环轮播图片并且用户可以从尽头滑到首图的特点 . package com.qf.day20_viewpager_demo4; i ...

  3. 安卓Eclipse如何快速修改工程名及包名

    修改工程名/包名,也是我们在开发中经常遇到的问题,比如我们在开发过程中突然觉得项目名不合适,或者根包名不合适想修改一下怎么办? 如上图所示工程,我想改变一下我的项目名,如把zzz改成xxx,把我的根包 ...

  4. SpringMVC源码分析--容器初始化(三)HttpServletBean

    在上一篇博客springMVC源码分析--容器初始化(二)DispatcherServlet中,我们队SpringMVC整体生命周期有一个简单的说明,并没有进行详细的源码分析,接下来我们会根据博客中提 ...

  5. Git管理工具对比(GitBash、EGit、SourceTree)

    Git管理工具对比(GitBash.EGit.SourceTree) GitBash是采用命令行的方式对版本进行管理,功能最为灵活强大,但是由于需要手动输入希望修改的文件名,所以相对繁琐. EGit是 ...

  6. 深入浅出EF之ModelFirst和DBFirst

    在上篇博文中,小编主要简单的介绍了一下EF的一些基础知识,其中,小编蜻蜓点水的提了一下ModelFirst和DBFirst,ModelFirst先设计实体,然后根据模型生成数据库,DBFirst根据数 ...

  7. javascript 把时间戳转为时间 ajax HTML拼装

    这个目的是记下来,好让我以后可以看一下,这个脚本可是反反复复写了我N天啊!! 全部写下,以备后用! Date.prototype.format = function(format) { var o = ...

  8. mysql进阶(二十二)MySQL错误之Incorrect string value: '\xE7\x81\xAB\xE7\x8B\x90...中文字符输入错误

    MySQL错误之Incorrect string value: '\xE7\x81\xAB\xE7\x8B\x90...' for column 'tout' at row 1中文字符输入错误 在实验 ...

  9. emacs24 颜色主题设置

    Emacs24 颜色主题设置 在Linux上写程序,永远绕不过的2个东西就是vi和emacs.emacs是早晚要接触的东西.本文就从配置颜色主题(color-theme)开始.用命令:$ sudo a ...

  10. ffmbc——为广播电视以及专业用途量身定制的FFmpeg

    无意中发现了个为广播电视以及专业用途量身定制的FFmpeg.也是开源的,记录之. ffmbc 全称是 FFMedia Broadcast,是个改版的FFmpeg,有如下功能: 创建可以导入Final ...