How to use ConstraintSet to set what like app:layout_constraintBottom_toBottomOf?

42 views Asked by At

Now,here is my question.

enter image description here

how can I use ConstraintSet's connect to set attr like 'app:layout_constraintBottom_toBottomOf="parent"'

1

There are 1 answers

0
Hai Hack On

Try this

TextView textView = new TextView(this);
textView.setId(R.id.text_id);
ConstraintSet set = new ConstraintSet();
set.clone(constraintLayout);
set.connect(textView.getId(), ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM, 0);
constraintLayout.addView(textView);
set.applyTo(constraintLayout);