如果依赖视图的可见性被设置为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>
在这种情况下,我的布局如下:
![enter image description here](https://istack.dev59.com/UHL6t.webp)
subtitle2
TextView的可见性设置为GONE
时,我的布局将如下所示:
![enter image description here](https://istack.dev59.com/bZTa2.webp)
GONE
文本视图基线。我不想在我的布局中留下空视图以避免复杂性并保持更清洁。 - novachevskyi