Android 布局(线性布局、相对布局)
Android 布局(线性布局、相对布局)
一、线性布局(LinearLayout)
<LinearLayout **** </LinearLayout> 1. orientation(布局方向)value=0 horizontal:水平 value=1 通过改变的Linear Layout的Orientation布局方向属性可以改变View的排列方式。 2.配对父视图:match_parent Layout_width/height的属性: fixed dp values(固定大小的宽高值) wrap_cntent(宽、高包含内容就可以) match_parent(匹配父视图的宽、高) 3.布局帐View的均衡分布:LinearLayut_weight(给每个View分配权重) 不管设备屏幕大小怎样,都是按照权重去平分屏幕 eg:
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"//想垂直平分屏幕就要设置height=“0dp”
android:layout_weight="1"
android:background="#4CAF50"
android:textSize="60dp"
android:text="Hello World!" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:textSize="60dp"
android:background="#2196F3"
android:text="Hello World!"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="I Love Code !"
android:textSize="60dp"
android:id="@+id/button"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="96dp" />效果如下:

以上就是线性布局的精要了、、、、、、
二、相对布局(RelativeLayout)
1.相对布局:父相对android :Layout_alignParent Top="true /false"
_align Parent bottom/_align Parent Left/align Parent left/
垂直居中:android :Layout_CenterVertical=“true”
ID:Android:id=
Layout
padding:内部(VIew自己处理)
margin:框架外部到边缘(View Group处理)

以上就是1B的学习了。
相关推荐
xfcyhades 2020-11-20
Michael 2020-11-03
业余架构师 2020-10-09
OuNuo0 2020-09-29
moses 2020-09-22
Angelia 2020-09-11
qinxu 2020-09-10
刘炳昭 2020-09-10
Nostalgiachild 2020-09-07
Nostalgiachild 2020-08-17
leavesC 2020-08-14
一青年 2020-08-13
AndroidAiStudy 2020-08-07
ydc0 2020-07-30
绿豆饼 2020-07-28