Android细节—— 权重预分配
来源:互联网 发布:万国数据事件 编辑:程序博客网 时间:2024/06/14 20:11
android:weightSum的作用在于当前LinearLayout 权重的预分配,其亮点在于:在某些情况下节约资源简化代码,不限制子控件的权重是否超出预分配值。
实用性举例:
(一):预分配
<?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:weightSum="4"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#d7bbbb"
android:layout_weight="1" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#8c2b2b"
android:layout_weight="1" />
</LinearLayout>
效果如图
预分配的好处在于填充控件时只填充其所占大小,其余的空余,节省了控件开销和市布局更简洁。
(二)非限制 (为了使效果显而易见第一个TextView权重设置为0.9)
<?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:weightSum="1"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#d7bbbb"
android:layout_weight="0.9" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#8c2b2b"
android:layout_weight="1" />
</LinearLayout>
效果如图:
代码里面加上触控监听和动画就有一个简单滑动菜单了,菜单宽度还是权重值适配性高
- Android细节—— 权重预分配
- 华为机试—字母权重分配方案
- 透析Android 中 权重使用及分配规则(layout_weight)
- Bug等级权重分配
- 主页权重合理分配
- nginx 权重分配
- OSGI系列 权重分配
- android权重
- android 权重
- android 权重
- 彩票调度算法权重分配
- ML—libSVM获得权重
- CSS权重,选择器—笔记
- Android中你也许不知道的线性布局Layout_weight属性权重比例分配原理
- 大中型网站细节优化提升整体权重
- 1简述seo细节成就高权重
- android权重android:layout_weight
- SKB 的分配细节.
- Hibernate3.2 断网之后报无法解析hibernate.cfg.xml错误
- xcode 连接 github
- Python Module_sys/random
- spring @AspectJ @annotation
- BZOJ 4292([PA2015]Równanie-数学)
- Android细节—— 权重预分配
- BZOJ 2797 [Poi2012]Squarks 数学
- AFNetworking怎么使用HTTPS协议
- BZOJ 3834 [Poi2014]Solar Panels 数学
- android studio快捷键
- linux下进程的最大线程数、进程最大数、进程打开的文件数
- Mini汽车的保养周期
- [MSSQL]SQL Server2000存储过程调试
- PHP利用P3P实现跨域