使用ConstraintLayout
我有2 TextView
,我希望當它們有足夠的空間來查看它們的內容時,它們彼此相鄰。但是,如果TextView A佔用大量空間並填充所有屏幕寬度,那麼比我希望TextView B在TextView A下移動,而不是仍然處於右側,但不可見(不在屏幕上)。只有當它們有足夠的空間時才能查看,否則請在底部
所以用下面的代碼,我得到了我的2 TextView
彼此相鄰。
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/text_view_a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp"
tools:text="a very long text ..." />
<TextView
android:id="@+id/text_view_b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
app:layout_constraintLeft_toRightOf="@+id/text_view_a"
app:layout_constraintTop_toTopOf="parent"
tools:text="some text" />
</android.support.constraint.ConstraintLayout>
我應該如何編輯此代碼片段,以便TextView B在TextView A下進入,如果他們沒有留給他任何空間的話?