使用惰性控件ViewStub实现布局动态加载
来源:互联网 发布:java 图片尺寸 编辑:程序博客网 时间:2024/05/29 13:49
ViewStub:是一个看不见,0大小的视图,不会占用内存,且动态加载布局,提高代码性能。
场景:xml布局有很多view,各种状态,如果这个时候把一切状态下的视图也一并写入就会使代码复杂,难懂,这个时候ViewStub就出现了。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.com/tools" 3 android:orientation="vertical" 4 android:layout_width="match_parent" 5 android:layout_height="match_parent" > 6 7 <!-- 静态加载 --> 8 <include 9 android:layout_width="wrap_content"10 android:layout_height="wrap_content"11 layout="@layout/includelayout" >12 </include>13 14 <ViewStub15 android:id="@+id/viewstub"16 android:layout_width="wrap_content"17 android:layout_height="wrap_content"18 android:layout_marginLeft="2dp"19 android:layout="@+layout/viewstublayout" >20 </ViewStub>21 22 <!-- 按钮 -->23 <LinearLayout 24 android:orientation="horizontal"25 android:layout_width="match_parent"26 android:layout_height="wrap_content" >27 <Button28 android:id="@+id/button_extend"29 android:layout_weight="1"30 android:layout_width="wrap_content"31 android:layout_height="wrap_content"32 android:text="展开宝贝详细描述" />33 <Button34 android:id="@+id/button_hide"35 android:layout_weight="1"36 android:layout_width="wrap_content"37 android:layout_height="wrap_content"38 android:text="隐藏宝贝详细描述" />39 </LinearLayout>40 41 </LinearLayout>
0 0
- 使用惰性控件ViewStub实现布局动态加载
- 使用惰性控件ViewStub实现布局动态加载
- android中ViewStub惰性加载布局
- ViewStub(惰性控件/延时加载)
- 动态加载布局ViewStub
- ViewStub惰性装载控件
- ViewStub惰性装载控件
- ViewStub惰性装载控件
- 使用 ViewStub 延迟加载布局
- 使用viewstub实现嵌套布局
- ViewStub(惰性加载View)详解
- 【Android 开发】:UI控件之 ViewStub 惰性装载控件的使用
- 安卓控件使用系列31:ViewStub惰性装载控件的使用方法
- ViewStub动态加载布局提高UI加载性能
- Android中关于布局文件延迟加载控件ViewStub
- Android中关于布局文件延迟加载控件ViewStub
- Android布局 使用LayoutInflater动态加载布局和操作控件
- android 利用ViewStub标签动态加载布局,节省资源
- ZOJ 1151 Word Reversal反转单词 (string字符串处理)
- Storyboard里面的几种Segue区别及视图的切换:push,modal,popover,replace和custom
- String[]的直接父类就是Object而不是Object[]
- UiAutomator 中文输入实现
- glibc源代码的阅读
- 使用惰性控件ViewStub实现布局动态加载
- Storyboard里面的几种Segue区别及视图的切换:push,modal,popover,replace和custom
- Java:Java socket编程时读取输入流时挂起问题
- 用freeswitch配置一些有用的功能
- 计算器
- 数据结构 --- 单链表
- MFC之绘图篇(开发平台VS2010)
- an interview question about fork
- 题目1432:叠筐(水题!!!)