Android Day23

内容

ⅠLinearLayout 线性布局

ⅡRelativelyLayout 相对布局

ⅢConstrainLayout 约束布局

具体内容

ⅠLinearLayout 线性布局

1.Margin与Padding的区别
Margin指的是控件与页面的边缘的间距
而Padding指的是控件内部与空间边缘的间距

2.边距的具体使用
layout_marginStart
layout_marginLeft 左边距

layout_marginRight
layout_marginEnd右边距

layout_marginTop上边距
layout_marginBottom下边距

使用layout_weight权重按比例分配
3.如何更改线性布局的方向
设置Orientation
Vertical表示纵向布局
Horizontal表示横向布局

ⅡRelativelyLayout 相对布局

1.必须能够确定每个控件的x、y、w、h
使用相对布局时不需要使用orientation

2.所有的布局类里面都维护一个LayoutParams extends MarginLayoutParams
用于管理当前这个布局子控件的布局
使用相对布局时不需要使用orientation

如何更改线性布局的方向
设置Orientation
Vertical表示纵向布局
Horizontal表示横向布局

所有的布局类里面都维护一个LayoutParams extends MarginLayoutParams
用于管理当前这个布局子控件的布局
Margin与Padding的区别
Margin指的是控件与页面的边缘的间距
而Padding指的是控件内部与空间边缘的间距

RelativelyLayout 相对布局
必须能够确定每个控件的x、y、w、h
使用相对布局时不需要使用orientation

在MarginLayout的基础上添加了对齐
当前这个控件和id为v1的控件右边对齐
android:layout_alignRight="@+id/v1"
android:layout_alignBottom="@+id/v1"

layout_centerHorizontal 横向对齐
layout_centerInParent 在父容器中对其居中对齐

ⅢConstrainLayout 约束布局

layout_constraintDimensionRatio 设置宽高比
layout_constraintDimensionRatio="w,1:2" 宽高比
layout_constraintDimensionRatio="h,1:2" 高宽比
2.xml文件中具体代码

    

    

    
    
    
    
    
    


    
    
    
    

你可能感兴趣的:(Android Day23)