ConstraintLayout属性

ConstraintLayout 约束布局  
使用可视化的方式编写界面,可以有效的解决布局的嵌套过多


属性:
app:layout_constraintLeft_toLeftOf="parent" 该控件的左侧与父布局对齐
app:layout_constraintLeft_toLeftOf="@id/viewB" 控件A与控件B左侧对齐
app:layout_constraintLeft_toRightOf="@id/viewB" 控件A在控件B的右侧
layout_constraintRight_toLeftOf
layout_constraintRight_toRightOf
layout_constraintTop_toTopOf
layout_constraintTop_toBottomOf
layout_constraintBottom_toTopOf
layout_constraintBottom_toBottomOf


app:layout_constraintBaseline_toBaselineOf
//Constrains the baseline of a child to the baseline of a target child (contains the target child id).
表示此控件与某个控件水平对齐


app:layout_editor_absoluteX
//The design time location of the left side of the child.
表示此控件在布局中X轴的绝对坐标点。


app:layout_editor_absoluteY
//The design time location of the right side of the child.
表示此控件在布局中Y轴的绝对坐标点


app:layout_constraintGuide_begi
//The distance of child (guideline) to the top or left edge of its parent.
表示在布局中引导线距顶部或左边框的距离(如:20dp表示距顶部或者左边框20dp)


app:layout_constraintGuide_end
//The distance of child (guideline) to the top or left edge of its parent.
表示在布局中引导线距底部的距离(如:10dp表示距顶部10dp)


app:layout_constraintGuide_percent
//The ratio of the distance to the parent's side
表示在整个布局中引导线距离左边框的百分百
(如:app:layout_constraintGuide_percent="0.5"表示距离左边框50%的位置)


app:layout_constraintHorizontal_bia
//The ratio between two connections when the left and right (or start and end) sides are constrained.
表示此控件在布局中的水平方向上的偏移百分百。


app:layout_constraintVertical_bia
//The ratio between two connections when the top and bottom sides are constrained.
表示此控件在布局中的的垂直方向上的偏移百分百。


app:layout_constraintDimensionRatio
//The child's side to constrain using dimensRatio.
表示两个控件的纵横比,而使用则需要把宽(layout_width)或者高(layout_height)设置为0dp,
根据另一个属性和比例, 计算当前属性, 如两个图片控件的显示大小,
app:layout_constraintDimensionRatio="4:3";


app:layout_goneMarginLeft
//The left margin to use when the target is gone.当目标消失时使用的左边距


app:layout_goneMarginTo
//The top margin to use when the target is gone.


app:layout_goneMarginRight
//The right margin to use when the target is gone


app:layout_goneMarginBottom
//The bottom margin to use when the target is gone.


app:layout_goneMarginStart
//The start margin to use when the target is gone.


app:layout_goneMarginEnd
//The end margin to use when the target is gone.


app:layout_constraintHorizontal_weight
等分类似于ll的weight


layout_constraintHorizontal_chainStyle
设置显示的样式(只用在第一个设置)

猜你喜欢

转载自blog.csdn.net/qq_36447701/article/details/80527123
今日推荐