how to MODIFY a constraint layout programmatically?

前端 未结 4 790
离开以前
离开以前 2021-02-18 13:56

Ive got a view like below :

 

        
4条回答
  •  梦谈多话
    2021-02-18 14:35

    I just found the answer in here and you can use ConstraintSet to achieve this like below:

    ConstraintSet constraintSet = new ConstraintSet();
    constraintSet.clone(context, R.id.activity_constraint);
    //for example lets change the vertical bias of tvDownVoteIcon
    float biasedValue = 0.2f;
    constraintSet.setVerticalBias(R.id.tvDownVoteIcon, biasedValue);
    //you can do any other modification and then apply
    constraintSet.applyTo( (ConstraintLayout) findViewById(R.id.activity_constraint));
    

提交回复
热议问题