Activities描述UI,处理人和屏幕的交互
布局管理器
- 相当于是css的flex、grid盒子的容器
线性布局(LinearLayout)
常用属性
android:idandroid:layout_width- 可选值:
- wrap_content:内容多少宽度多少
- match_content:匹配父空间,父空间多少多少
- 可选值:
android:layout_heightandroid:layout_marginandroid:layout_paddingandroid:backgroundandroid:orientation- 方向:
- vertical:垂直
- 方向:
android:gravity- 在容器中的位置,类似flex布局的
align-item,just-content- center_horizontal:水平居中
- center_horizontal:垂直居中
- center:水平垂直居中
- 在容器中的位置,类似flex布局的
layout_weight:权重
---<a name="eGxA5"></a>### 相对布局(RelativeLayout)<a name="MEU0t"></a>#### 常用属性1. `android:layout_toLeftOf`1. 在参照物的左边2. `android:layout_toRightOf`2. `android:layout_alginBottom`1. 和参照物底部对齐4. `android:layout_alginParentBottom`1. 和父控件底部对齐5. `android:layout_below`1. 在参照物下边<a name="YNoWa"></a>#### 小demo```xml<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#10aabb"><Viewandroid:id="@+id/view_0"android:layout_width="100dp"android:layout_height="100dp"android:layout_alignParentBottom="true"android:background="#aabbcc"/><Viewandroid:id="@+id/view_1"android:layout_width="100dp"android:layout_height="100dp"android:background="#202020"/><Viewandroid:id="@+id/view_2"android:layout_width="100dp"android:layout_height="100dp"android:background="#33ff11"android:layout_toRightOf="@id/view_1"/></RelativeLayout>

常用控件
View
View是所有控件的父类,所有的控件都继承View的属性
