(1)Android UI元素
视图(View)
🌟🌟🌟常见的子类及功能:
TextView 文本视图
EditText 编辑文本框
Button 按钮
Checkbox 复选框
RadioGroup 单选按钮组
别的用到的先查就行!
视图容器(View Group)
布局管理(Layout)
ViewGroup的子类,所有的布局都可以作为容器。
LinearLayout(线性布局)、RelativeLayout(相对布局)、TableLayout(表格布局)、AbsoluteLayout(绝对布局)、ConstrainLayout(约束布局)
Activity
Fragment
(2)界面布局
(1)LinearLayout(线性布局):垂直或者水平方向排列
设定方法:android:orientation="vertical"
对齐方式:布局的对齐方式 android:gravity
元素的对齐方式 android:layout_gravity
(2)TableLayout(表格布局):以行列的方式布局子组件
行数的指定 是由<TableRow> </TableRow>标签来指定,
列数的指定 是由<TableRow> </TableRow>中元素的个数来指定
特殊属性: stretchColumns :当内容少的时候,指定哪一列伸展占满屏幕。序号从0开始
shrinkColumns:当内容都的时候,指定那一列可以换行显示
collapseColumns:隐藏指定列 序号从0开始
(3)RelativeLayout(相对布局):子组件的位置总是相对于兄弟组件或父容器
【上下左右中】布局 的实现步骤
1. 确定基准点【中】的位置 : 【中】位于容器的中间,android:layout_centerInParent="true"
2. 给基准点元素设定Id,让别人能找到它: android:id="@+id/mid"
3. 添加【上】,位置是在【中】的上边。与【中】左对齐:android:layout_alignLeft="@id/mid" android:layout_above="@id/mid"
4.添加【下】,位置是在【中】的下边。与【中】左对齐:android:layout_alignLeft="@id/mid" android:layout_bellow="@id/mid"
5. 添加【左】,位置在【中】的左边,与【中】上对齐 android:layout_toLeftOf="@id/mid" android:layout_alignTop="@id/mid"
6. 添加【右】,位置在【中】的右边,与【中】上对齐android:layout_toRightOf="@id/mid" android:layout_alignTop="@id/mid"
(4)AbsoluteLayout(绝对布局):
绝对布局:指定元素的绝对位置 ->不足:不能自适应不同分辨率的屏幕
指定XY坐标点的位置: android:layout_y android:layout_x
(5)ConstrainLayout(约束布局):指定四个边界在指定组件的哪个边界上