在 android 中以编程方式等同于 layout_constraintRight_toLeftOf 是什么?

What is the equivalent of layout_constraintRight_toLeftOf programmatically in android?

我想以编程方式向 ConstraintLayout 中的 TextView 添加一些约束。我知道我必须使用 ConstraintSet,但我不知道如何添加 xml 属性:layout_constraintRight_toLeftOf(及其等效项)在 [=22] 中的 textView =] 在 android 中。

感谢任何帮助!!

可以这样设置,

ConstraintSet constraintSet = new ConstraintSet();
constraintSet.clone(layout); // root layout

// If you want to align parent to the layout left
constraintSet.connect(textView.getId(), ConstraintSet.LEFT, layout.getId(), ConstraintSet.LEFT);

// If you want to align to the left of one more textview - second text view
constraintSet.connect(textView.getId(), ConstraintSet.RIGHT, textView1.getId(), ConstraintSet.LEFT);

/*______________________________
|      Text1     Text2       |
|                            |*/
constraintSet.applyTo(layout);