item_description 仍然位于排列的底部,而不是位于 item_title 的右側。
有什么建議么?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical”>
<ImageView
… />
<TextView
android:id="@ id/item_title”
android:layout_width="150dp"
…. />
<TextView
android:id="@ id/item_description”
app:layout_constraintTop_toTopOf="@id/item_title”
app:layout_constraintStart_toEndOf="@id/item_title" />
</LinearLayout>
uj5u.com熱心網友回復:
嘗試這個 :
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical”>
<ImageView
… />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal”>
<TextView
android:id="@ id/item_title”
android:layout_width="150dp"
…. />
<TextView
android:id="@ id/item_description”
app:layout_constraintTop_toTopOf="@id/item_title”
app:layout_constraintStart_toEndOf="@id/item_title" />
</LinearLayout>
</LinearLayout>
uj5u.com熱心網友回復:
您不能僅在 ConstraintLayout 上使用線性布局上的約束。
線性布局專案將始終按照您指定的順序出現。
將頂級專案更改為ConstraintLayout
uj5u.com熱心網友回復:
LinearLayout將視圖排成一行,一個接一個,水平或垂直排列(您已在此處指定)。您可以將兩個“水平”元素嵌套在另一個水平元素中LinearLayout:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical”>
<ImageView
… />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal”>
<TextView
android:id="@ id/item_title”
android:layout_width="150dp"
…. />
<TextView
android:id="@ id/item_description” />
</LinearLayout>
</LinearLayout>
或使用 a ConstraintLayout,您想通過在底部添加這些約束來嘗試使用它TextView- 但如果您將 更改LinearLayout為ConstraintLayout,則需要對所有內容進行約束:
<ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@ id/imageView"
app:layout_constraintTop_toTopOf="parent”
app:layout_constraintStart_toStartOf="parent”
app:layout_constraintEnd_toEndOf="parent”
… />
<TextView
android:id="@ id/item_title”
android:layout_width="150dp"
app:layout_constraintTop_toBottomOf="@id/imageView”
app:layout_constraintStart_toStartOf="parent”
…. />
<TextView
android:id="@ id/item_description”
app:layout_constraintTop_toTopOf="@id/item_title”
app:layout_constraintStart_toEndOf="@id/item_title" />
</ConstraintLayout>
在這里猜測一下你想要的布局,但你明白了!
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/486626.html
