android 布局文件 layout_weight用法
16lz
2021-12-04
情景一, 布局文件代码如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1" android:text="TextView1" /> <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="9" android:text="TextView2" /></LinearLayout>
parent view中 android:layout_width="fill_parent" 两个child view:
TextView1 android:layout_weight="1"
TextView2 android:layout_weight="9"
宽度比例效果图如下:
结论:当linearLayout为android:layout_width="fill_parent"子view中android:layout_weigh表示权重比例几分之几的概念,此条件下:TextView1宽度为整个宽度的1/10;
当linearLayout为android:layout_width="wrap_content"子view中android:layout_weigh表示权重比例不起作用没有效果
更多相关文章
- Android实现九宫格
- shape .xml
- Android(安卓)学习笔记--android基本注意点
- android流式布局热门标签的实现
- ImageView的android:maxHeight,android:minHeight的正确设置
- ConstraintLayout子View android:minHeight 无效解决
- ImageView的android:maxHeight,android:minHeight的正确设置
- android main.xml分析。。一点点补充
- Android实现九宫格 主界面应用列表效果