1

I searched everywhere, How to clear constraints of Widgets inside ConstraintLayout, the one result that I found is at stack OverFlow in this link : here

But the answer of this question, doesn't work in my case, however, my question is how could i clear constraint of the widget (E.g ImageView) inside ConstraintLayout programmatically. here's a picture that illustrates what am asking for,thank's. enter image description here

Abderazak Amiar
  • 776
  • 7
  • 22

2 Answers2

2

create clone of current set and then apply new constraints to it then apply it to view

ConstraintSet constraintSet = new ConstraintSet();
constraintSet.clone(constraintLayout);
constraintSet.connect(R.id.imageView,ConstraintSet.RIGHT,R.id.check_answer1,ConstraintSet.RIGHT,0);
constraintSet.connect(R.id.imageView,ConstraintSet.TOP,R.id.check_answer1,ConstraintSet.TOP,0);
constraintSet.applyTo(constraintLayout);
Kishan Thakkar
  • 429
  • 4
  • 11
1

Look at your xml constraints of your view to find out which constraint to clear, it happened to me to clear LEFT while it was constrained with START.

Slimane amiar
  • 934
  • 12
  • 27