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"?>        

效果图:

              android -------- ConstraintLayout 约束属性(二)_第1张图片

 

 

layout_constraintBaseline_toBaselineOf (View A 内部文字与 View B 内部文字对齐)

举例:

<?xml version="1.0" encoding="utf-8"?>    

效果图:

            android -------- ConstraintLayout 约束属性(二)_第2张图片

    

 

几个属性的联系

更多相关文章

  1. Android基于ViewFilpper实现文字LED显示效果示例
  2. android控件的属性
  3. Android GPS (当前位置 & GPS信息更新)
  4. 安卓新手之路——关于layout一些属性的整理
  5. ViewPager中属性android:flipInterval="30" android:persistentD

随机推荐

  1. Android Intent实现页面跳转的方法示例
  2. Android(安卓)组件系列之Activity的传值
  3. android之逐帧动画
  4. Android(安卓)Shape控件美化实现代码
  5. android ListView Item和CheckBox、Butto
  6. Android评分控件RatingBar使用实例解析
  7. Android(安卓)- toolbar 优化 title修改
  8. [Android]调试webview
  9. 我来说说Android touch 系统的设计哲学
  10. (转)Android AndroidManifest.xml文件的and