ConstraintSet.createHorizontalChain方法

最近学习了大婶们的constraintLayout用法,

https://github.com/xitu/gold-miner/blob/master/TODO/constraint-layout-animations-dynamic-constraints-ui-java-hell.md

而此时版本已经是1.1.2

implementation 'com.android.support.constraint:constraint-layout:1.1.2'

发现有些功能已经官方更新了,比如createHorizontalChain方法

public void createHorizontalChain(int leftId, int leftSide, int rightId, int rightSide, int[] chainIds, float[] weights, int style) {
    this.createHorizontalChain(leftId, leftSide, rightId, rightSide, chainIds, weights, style, 1, 2);
}

参数已经是7个了,而在学习中发现代码设置chain已经没有这个方法,经过调试修改为以下代码,实现了效果

mApplyConstraintSet.createHorizontalChain(R.id.constraintLayout,ConstraintSet.LEFT,R.id.constraintLayout,ConstraintSet.RIGHT,new int[]{R.id.button1,R.id.button2,R.id.button3},null, ConstraintWidget.CHAIN_SPREAD);

leftId 基准的左边控件id,可以是guideLine

leftSide 须为ConstraintSet.LEFT或者ConstraintSet.RIGHT,其他参数运行出错

rightId 基准的右边控件id,可以是guideLine

rightSide 须为ConstraintSet.LEFT或者ConstraintSet.RIGHT,其他参数运行出错

 

你可能感兴趣的:(android,ConstraintSet)