【问题标题】:How to use ConstraintSet to set what like app:layout_constraintBottom_toBottomOf?如何使用 ConstraintSet 设置类似 app:layout_constraintBottom_toBottomOf 的内容?
【发布时间】:2020-11-03 07:48:04
【问题描述】:

现在,这是我的问题。

如何使用ConstraintSet 的连接来设置属性,如'app:layout_constraintBottom_toBottomOf="parent"'

【问题讨论】:

    标签: android android-constraintlayout constraintset


    【解决方案1】:

    试试这个

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

    【讨论】:

      猜你喜欢
      • 2022-01-22
      • 2010-11-22
      • 1970-01-01
      • 2016-09-28
      • 2019-09-22
      • 1970-01-01
      • 2018-11-29
      • 2020-06-29
      相关资源
      最近更新 更多