1
我想用下面的代码将文本视图添加到父级的右端。但它不起作用。如何在约束布局中以编程方式实现layout_constraintEnd_toEndOf?
ConstraintSet constraintSet = new ConstraintSet();
TextView mValue1 = new TextView(getContext());
mValue1.setText("Value 1");
mValue1.setId(R.id.rightLabel1);
addView(mValue1);
constraintSet.clone(this);
constraintSet.connect(mValue1.getId(), ConstraintSet.TOP, this.getId(), ConstraintSet.TOP);
constraintSet.connect(mValue1.getId(), ConstraintSet.END, this.getId(), ConstraintSet.END);
constraintSet.applyTo(this);