我正在嘗試1.1.0-beta1中的新屏障功能。它工作正常,但有這種用例,我似乎無法數字或(或可能是ConstraintLayout?)ConstraintLayout with Barriers;如何根據大小約束屏障底部/頂部
我想要完成的是:我有一個imageview左邊,標題和副標題textview右側的textview。 Imageview是固定的高度。我有一個按鈕,即底部約束到圖像視圖的底部但是應該被頂部約束到字幕textview的底部,如果subtitletextview比imageview高。
(順便說一句我也試過有它底部約束到的ImageView的底部,topconstrained到TextView的底部,並給它1.0對底部的偏見,但有大量的文字的情況下沒有工作)
有了障礙,我只能獲得按鈕上方受限於屏障的底部(或頂部,似乎是相同的)
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@color/blue"/>
<ImageView
android:id="@+id/imageView4"
android:layout_width="0dp"
android:layout_height="150dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:scaleType="centerCrop"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/books"/>
<ImageView
android:id="@+id/imageView6"
android:layout_width="124dp"
android:layout_height="156dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView4"
app:srcCompat="@android:drawable/radiobutton_on_background"/>
<TextView
android:id="@+id/textView4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:text="TextView"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toRightOf="@+id/imageView6"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView4"/>
<TextView
android:id="@+id/textView5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Lorem Ipsum je fiktívny text, používaný pri návrhu tlačovín a typografie. Lorem Ipsum je štandardným výplňovým textom už od 16. storočia, keď neznámy tlačiar zobral sadzobnicu plnú tlačových znakov a pomiešal ich, aby tak vytvoril vzorkovú knihu. Prežil nielen päť storočí, ale aj skok do elektronickej sadzby, a pritom zostal v podstate nezmenený. Spopularizovaný bol v 60-tych rokoch 20.storočia, vydaním hárkov Letraset, ktoré obsahovali pasáže Lorem Ipsum, a neskôr aj publikačným softvérom"
app:layout_constraintLeft_toLeftOf="@+id/textView4"
app:layout_constraintRight_toRightOf="@+id/textView4"
app:layout_constraintTop_toBottomOf="@+id/textView4"/>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
app:layout_constraintTop_toBottomOf="@+id/textView5"
app:layout_constraintRight_toRightOf="parent"/>
</android.support.constraint.ConstraintLayout>
請用你試過的xml更新你的問題。 –
它的微不足道的例子,但我不知道它添加它 – urSus