android -------- ConstraintLayout 约束属性(二)
ConstraintLayout 介绍(一)
ConstraintLayout 最基本的属性控制有以下几个,即 layout_constraintXXX_toYYYOf 格式的属性,即将“View A”的方向 XXX 置于 “View B”的方向 YYY 。当中,View B 可以是父容器即 ConstraintLayout ,用“parent”来表示
相对位置属性如下:
layout_constraintLeft_toLeftOf :当前View的左侧和另一个View的左侧位置对齐,与RelativeLayout的alignLeft属性相似
layout_constraintLeft_toRightOf :当前view的左侧会在另一个View的右侧位置 与RelativeLayout的toRightOf属性相似
layout_constraintRight_toLeftOf :当前view的右侧会在另一个View的左侧位置 与RelativeLayout的toLeftOf属性相似
layout_constraintRight_toRightOf :当前View的右侧和另一个View的右侧位置对齐,与RelativeLayout的alignRight属性相似
layout_constraintTop_toTopOf :头部对齐,与alignTop相似
layout_constraintTop_toBottomOf :当前View在另一个View的下侧 与below相似
layout_constraintBottom_toTopOf :当前View在另一个View的上方 与above相似
layout_constraintBottom_toBottomOf :底部对齐,与alignBottom属性相似
layout_constraintBaseline_toBaselineOf :文字底部对齐,与alignBaseLine属性相似
layout_constraintStart_toEndOf :同left_toRightOf
layout_constraintStart_toStartOf :同left_toLeftOf
layout_constraintEnd_toStartOf :同right_toLeftOf
layout_constraintEnd_toEndOf :同right_toRightOf
举例:
<?xml version="1.0" encoding="utf-8"?>
效果图:
layout_constraintBaseline_toBaselineOf (View A 内部文字与 View B 内部文字对齐)
举例:
<?xml version="1.0" encoding="utf-8"?>
效果图:
几个属性的联系
更多相关文章
- Android基于ViewFilpper实现文字LED显示效果示例
- android控件的属性
- Android GPS (当前位置 & GPS信息更新)
- 安卓新手之路——关于layout一些属性的整理
- ViewPager中属性android:flipInterval="30" android:persistentD