android中以编程方式等效的layout_constraintRight_toLeftOf是什么?

时间:2017-08-23 19:54:14

标签: java android android-constraintlayout

我想以编程方式在ConstraintLayout内为ConstraintSet添加一些约束。我知道我必须使用layout_constraintRight_toLeftOf,但我不知道如何在android中的Java textView中添加xml属性:angular.module("core") .filter('runTimePlusSetup', function () { (及其等价)。

任何帮助表示赞赏!!

1 个答案:

答案 0 :(得分:1)

您可以这样设置,

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);