Android(安卓)LinearLayout线性布局
16lz
2021-12-04
线性布局LinearLayout是一个视图容器,用于使所有子视图在单个方向保持对齐<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <TextView android:layout_width="200dp" android:layout_height="90dp" android:background="#4593Ec" android:gravity="center" android:text="1" android:textColor="@color/white" android:textSize="25sp"/> <TextView android:layout_width="100dp" android:layout_height="90dp" android:background="#7DB145" android:gravity="center" android:text="2" android:textColor="@color/white" android:textSize="25sp"/> <TextView android:layout_width="80dp" android:layout_height="90dp" android:background="#F10000" android:gravity="center" android:text="3" android:textColor="@color/white" android:textSize="25sp"/>LinearLayout>android:orientation="vertical" 垂直方向下(图1)android:orientation="horizontal" 水平方向下(图2)
布局权重:通过给子视图设置权重值,来分配子视图所占空间的权重(比例)<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="100dp" android:background="#3c3f41"/> <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="2" android:background="#ff5722"/> <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="#4795ec"/>LinearLayout>
更多相关文章
- 第五章 Android(安卓)Scroll 分析
- Android(安卓)中文 API (36) ―― Toast
- Android(安卓)中文 API (102)―― CursorAdapter
- Android(安卓)- 信息列表页面【仿】淘宝App
- android一些认识
- android Gallery(画廊)以及BaseAdapter
- Android(安卓)- 小功能 - android手动开启或者关闭输入法
- MVP -----个人理解与示例(android例子 实现)
- Android(安卓)gallery详解