LinearLayout布局之weight
weight的正确使用方法:
先设置android:layout_width="0dp" 或者android:layout_height="0dp"
然后再去调配权重,而此时的weight也非常好理解: weight就是比重。
weight的错误使用方法:
android:layout_width="match_parent"
android:layout_width="wrap_content"
两种情况下该如何设置weight. 因为这样设置根本就是错误的用法.
下面是来自SDK的一句话:In order to improve the layout efficiency when you specify the weight, you should change the width of theEditTextto be zero (0dp). Setting the width to zero improves layout performance because using"wrap_content"as the width requires the system to calculate a width that is ultimately irrelevant because the weight value requires another width calculation to fill the remaining space.它的大致意思就是说: 我们如果在某个方向上使用了weight ,那么我们必须在对应的方向上将width设置为0dp. 它告诉了我们设置为0dp是因为使用weight,系统是采用了另外一套计算占用空间大小的算法的.(the weight value requires another width calculation to fill the remaining space.)
更多相关文章
- LinearLayout 内部 挂件 居中
- Android——新手指引 指定View高光显示自定义控件
- AndroidManifest.xml的Service元素 android:process设置
- android创建桌面快捷方式(启动目标非项目的启动页)
- Android(安卓)Selector Shape使用详解
- Android之背景图片设置为重复而不是默认的拉伸
- Android(安卓)GridView 通过seletor 设置状态和默认状态
- 申请Android(安卓)Maps API Key,以及出现的错误
- Android中贪吃蛇游戏的学习(三)