"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. chromium出现输入密码解锁登录密钥环

    chromium出现输入密码解锁登录密钥环 在ubuntu 16.04上安装了Chromium出现对话框,如下所示: 因为密码框截图困难,这个是网上图片. 点取消就可以使用,但是每次都这样很烦,百度后 ...

  2. springMVC源码分析--HandlerInterceptor拦截器调用过程(二)

    在上一篇博客springMVC源码分析--HandlerInterceptor拦截器(一)中我们介绍了HandlerInterceptor拦截器相关的内容,了解到了HandlerInterceptor ...

  3. JAVA面向对象-----接口与类、接口之间的关系

    接口与类.接口之间的关系 大家之前都知道类与类之间的关系继承,那么接口与类之间又是怎样子的关系呢? 接口与类之间是实现关系.非抽象类实现接口时,必须把接口里面的所有方法实现.类实现接口用关键字impl ...

  4. Java基本语法-----java常量

    1常量的概述 常量是指在程序运行过程中其值不能改变的量. 2常量类型 Java中常量的分类: 整数常量 : 所有整数 小数常量 : 所有小数 布尔常量 : 只有true和false 字符常量 :使用' ...

  5. Android实现自动更新功能

    Android实现自动更新功能 Android自动更新的功能可以使用第三方的SDK来实现,但是类似友盟,就不支持x86手机的自动更新,科大讯飞,弹窗是全局的,小米手机就会默认把弹窗权限关掉不允许弹出提 ...

  6. AMH 5.X下安装 Flarum

    如果移动端访问不佳,请尝试–>Github版 背景 最近无意间发现几个开源软件的Bug反馈系统使用的是Flarum,Flarum是一款优雅简洁论坛软件,看起来还是相当不错的,一时抑制不住想要尝试 ...

  7. 13 获取外部数据库 以及数据库游标适配器(SimpleCursorAdapter)

    获取外部数据库 API SQLiteDatabase db = SQLiteDatabase.openDatabase(path, factory, flags); 参数详解: path:数据库路径 ...

  8. 浅谈Android布局

    在前面的博客中,小编介绍了Android的极光推送以及如何实现登录的一个小demo,对于xml布局页面,摆控件这块的内容,小编还不是很熟练,今天小编主要简单总结一下在Android中的布局,学习过An ...

  9. 03SpringMVC,Spring,Hibernate整合(Date时间转换)

     项目结构 2 web.xml的配置内容如下: <?xmlversion="1.0"encoding="UTF-8"?> <web-app ...

  10. Windows7 x64 跨平台开发环境安装配置

    ======================================================================= Windows7 x64 跨平台开发环境安装配置 201 ...