?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
//线性布局
android:layout_width="match_parent"
宽度 match_parent 匹配(填充满)父组件。wrap_content 包裹内容
android:layout_height="match_parent"
//高度 包裹内容
android:orientation="horizontal">
//设置水平or垂直 horizontal 水平 vertical 垂直
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
高宽皆为包裹内容
android:text="red"
//内容设置为 red
android:background="#ff0000"
//颜色设置为红色
android:layout_weight="1"
//权重(比例)为1
/>
<LinearLayout
//布局内可以嵌套布局,但不建议太多,会影响性能
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b"
android:background="#ff00ff"
android:layout_weight="1"/>
//权重(比例)也为1,权重相同时均分布局,权重越大比例越大
</LinearLayout>
零基础安卓自学第一天LinearLayout
于 2022-01-19 22:24:29 首次发布