复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24<?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" > <TextView android:id="@+id/text1" android:text="thired" android:background="#fff000" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" /> <TextView android:id="@+id/text2" android:text="123456789123456789132456789" android:background="#449000" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" /> </LinearLayout>
很多新手刚学的时候,总是以为layout_weight=“1”是子控件平分父控件的剩余空间。其实不然...
应该说layout_weight是子控件的剩余空间平分父控件的剩余空间。如果有一个控件的文本占用位置很多的话,那么使用layout_weight=“1” 它的空间就会比另外一个大很多。
最后
以上就是发嗲乌龟最近收集整理的关于关于layout_weight="1"的用法的全部内容,更多相关关于layout_weight="1"内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复