LinearLayout布局中layout_weight的用法
16lz
2021-01-23
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingLeft="16dp" android:paddingRight="16dp" android:orientation="vertical" > <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="@string/to" /> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="@string/subject" /> <EditText android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="top" android:hint="@string/message" /> <Button android:layout_width="100dp" android:layout_height="wrap_content" android:layout_gravity="right" android:text="@string/send" /></LinearLayout>
第三个组件因为设置了layout_weight,会随着屏幕的大小变化自动伸缩;没有设置layout_weight的将不会变化。
更多相关文章
- android:屏幕自适应
- Android 屏幕实现上下翻转
- Android设定屏幕只竖屏或只横屏的两种方式
- Android显示调用App内部组件/第三方App内组件
- Android 解决setRequestedOrientation之后手机屏幕的旋转不触发o
- Android之屏幕切换使用技巧
- Android 中屏幕点击事件的实现