android学习之控件的显示和隐藏
来源:互联网 发布:bigworld源码 编辑:程序博客网 时间:2024/06/05 20:54
在android开发过程中,我们有时会需要控制控件的显示和隐藏,来达到一定的ui效果。
而android的View类为我们提供了这样的属性和方法,以是的我们可以控制控件的显示和隐藏;
比如这段代码:
<?xml version="1.0"encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button1" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button2" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button3" />
</LinearLayout>
在水平布局中有3个按钮,权重为1,3个按钮将水平方向上的空间进行了平分。
我是是可以通过, android:visibility=""来控制控件的显示、隐藏、消失的
android:visibility有3个值invisible(隐藏)、visible(显示)、gone(消失);
默认值为visible,invisible是控制控件不可见,但仍旧占据布局空间,gone是控件不仅是不可见且不再占据布局空间。
Visible:
Invisible:
Gone:
我们不仅可以通过在布局文件中设置android:visibility的值来控制控件的显示和隐藏,我们同样也可在代码中控制,这时我们需要调用到方法:setVisibility();在方法中我们来制定控件的显示状态值,View.GONE/ View.VISIBLE/ View.INVISIBLE
- android学习之控件的显示和隐藏
- android 控件的隐藏和显示
- android 控件的隐藏和显示
- Android中控件的隐藏和显示
- Android控件显示和隐藏
- Android控件显示和隐藏
- Android控件显示和隐藏
- Android 控件显示和隐藏
- Android控件显示和隐藏
- Android控件显示和隐藏
- Android中的布局和控件的隐藏和触发显示
- 【学习】ListView中控制子控件的隐藏和显示
- Android 动画1--View控件的显示和隐藏效果
- Android 控件重复初始化影响隐藏和显示的控制
- Android 动画1--View控件的显示和隐藏效果
- Android 动画1--View控件的显示和隐藏效果
- Android控件显示和隐藏案例详解
- android显示隐藏控件
- @RequestMapping 基本用法 spring mvc
- 如何快速查看并定位网页元素代码
- 博客-初篇
- java设计模式之代理模式(转,哈哈,故事很精彩)
- 接口测试总结
- android学习之控件的显示和隐藏
- Java中创建对象的5种方式
- 我与Android有个约会
- HDOJ--2012素数判定
- Mac 修改hosts文件
- Codeforces Round #362 (Div. 2) 题解
- 自定义控件其实很简单2/12
- r-fcn
- BOW-FisherVector-VLAD