【发布时间】:2021-02-17 09:00:41
【问题描述】:
如果从属视图可见性设置为 GONE,是否有任何方法可以重新调整 TextView 的基线约束?
我的布局代码:
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST TITLE"
android:textColor="@color/black"
android:textSize="24sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
<TextView
android:id="@+id/subtitle1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SUBTITLE 1"
android:textSize="11sp"
app:layout_constraintBaseline_toBaselineOf="@+id/subtitle2"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/subtitleSpace"
app:layout_constraintRight_toRightOf="parent"/>
<android.support.v4.widget.Space
android:id="@+id/subtitleSpace"
android:layout_width="12dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toRightOf="@+id/subtitle1"
app:layout_constraintRight_toLeftOf="@+id/subtitle2"/>
<TextView
android:id="@+id/subtitle2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="SUBTITLE 2"
android:textSize="14sp"
app:layout_constraintLeft_toRightOf="@+id/subtitleSpace"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/title"/>
</android.support.constraint.ConstraintLayout>
当我将 subtitle2 TextView 可见性设置为 GONE 时,我的布局将如下所示:
所以我想知道如果缺少依赖视图,是否有一些约束可以重新对齐基线。
【问题讨论】:
标签: android android-constraintlayout