前面的

ConstraintLayout 介绍(一)

android -------- ConstraintLayout 约束属性(二)

此博文主要讲解:

app:layout_constraintHorizontal_bias
app:layout_constraintDimensionRatio

 

 

1:app:layout_constraintDimensionRatio(宽高比/百分比布局)

这个属性感觉非常实用,按照比例来分配布局

案例:

<?xml version="1.0" encoding="utf-8"?>                        
app:layout_constraintDimensionRatio="h,16:8"  按照宽高的比例,也可以
app:layout_constraintDimensionRatio="w,1:3"   按照高宽的比例效果图:

              

 

2:app:layout_constraintHorizontal_bias(偏移量比)

链条分为水平链条和竖直链条两种,分别用 layout_constraintHorizontal_chainStyle 和 layout_constraintVertical_chainStyle 两个属性来设置
属性值有以下三种:

  • spread
  • spread_inside
  • packed

默认值为 spread

可以通过下图来理解各个参数值的含义

   

 

举例(水平的)

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

效果图:

  

 

垂直的:

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

效果图:

          

 

 

参考文档: 

https://developer.android.google.cn/reference/android/support/constraint/ConstraintLayout#Chains

https://constraintlayout.com/basics/create_chains.html

https://www.jianshu.com/p/b884b8c46584

更多相关文章

  1. 读取SIM卡信息
  2. android 自定义权限
  3. android属性动画最简单使用
  4. Android(安卓)DrawerLayout 使用
  5. 使用ScheduledExecutorService延时关闭一个全屏的对话框
  6. Android中一种ThreadPool的实现
  7. Android(安卓)ListView中有Button,ItemClick事件失效
  8. Android(安卓)popupWindow点击某个控件在其下面显示弹窗,例如淘
  9. 不匀速移动的Animaiton实例XML

随机推荐

  1. Android(安卓)手机上安装并运行 Ubuntu 1
  2. 谈谈移动应用开发环境
  3. Android如何扩大按钮点击区域
  4. Android软件广告屏蔽方法及代码
  5. Android(安卓)性能优化之使用MAT分析内存
  6. Android: NDK编程入门笔记
  7. 如何使用 Eclipse 给 Android(安卓)模拟
  8. 关于android的9path图片处理
  9. windows下用ADT进行android NDK开发的详
  10. Android(安卓)之 IntentFilter 详解