ConstraintLayout布局动态设置

记录下布局依赖变更,clone复制原先布局,一定要写,
margin只能设置top,down
applyTo应用布局

 ConstraintSet set = new ConstraintSet();
            set.clone(clDetail);
            set.connect(divider.getId(), ConstraintSet.TOP, recyclerView.getId(), ConstraintSet.BOTTOM);
            set.setMargin(divider.getId(), ConstraintSet.TOP, DensityUtils.dip2px(getContext(), 3));
            set.applyTo(clDetail);

你可能感兴趣的:(Android)