"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. 剑指Offer——常用SQL语句、存储过程和函数

    剑指Offer--常用SQL语句.存储过程和函数 常用SQL语句 1.在MySQL数据库建立多对多的数据表关系 2.授权.取消授权 grant.revoke grant select, insert, ...

  2. ThinkPHP 初探

    准备 ThinkPHP下载 Eclipse-for-php 如何使用 放置位置 检验引用效果 效果 路由 调试之模板的使用 前提 生产模式 开发模式 添加完相应的路径以及模板文件后 总结 对国人开发的 ...

  3. SLAMCN资料收藏转载

    网页链接地址:http://www.slamcn.org/index.php/%E9%A6%96%E9%A1%B5 资料非常丰富,内容如下: 首页 目录 [隐藏]  1 SLAM 介绍 1.1 什么是 ...

  4. Leetcode解题-链表(2.2.0)基础类

    1 基类的作用 在开始练习LeetCode链表部分的习题之前,首先创建好一个Solution基类,其作用就是: Ø  规定好每个子Solution都要实现纯虚函数test做测试: Ø  提供了List ...

  5. Afianl加载网络图片(续)

    上一篇已经讲了如何利用Afianl加载网络图片和下载文件,这篇文章将继续讲解使用Afinal加载网络图片的使用,主要结合listview的使用: 看效果图: listview在滑动过程中没用明显卡顿, ...

  6. Android必知必会-带列表的地图POI周边搜索

    如果移动端访问不佳,请尝试–> Github版 2016-08-22 更新 注意:在 Activity 代码中的onPoiSearched(PoiResult result, int rCode ...

  7. 【java集合框架源码剖析系列】java源码剖析之LinkedList

    注:博主java集合框架源码剖析系列的源码全部基于JDK1.8.0版本. 在实际项目中LinkedList也是使用频率非常高的一种集合,本博客将从源码角度带领大家学习关于LinkedList的知识. ...

  8. 详解EBS接口开发之更新供应商付款方法

    更新供应商地点层的付款方法API DECLARE --API 参数 l_external_payee_rec_type iby_disbursement_setup_pub.external_paye ...

  9. Java-IO之BufferedInputStream(缓冲输入流)

    BufferedInputStream是缓冲输入流,继承于FilterInputStream,作用是为另一个输入流添加一些功能,本质上是通过一个内部缓冲数组实现的.例如,在新建某输入流对应的Buffe ...

  10. Cocos2D:塔防游戏制作之旅(五)

    打开HelloWorldLayer.h文件,添加以下实例变量(在@interface行的花括号之后): NSMutableArray *towerBases; 将HelloWorldLayer.m文件 ...