Constraintlayout Doesn't Respect Max Height
I'm trying to create a layout composition using ConstraintLayout. In order to simplify my case, my layout should have three parts: The first layout (in red), that should grow acco
Solution 1:
android:layout_height="wrap_content"app:layout_constraintHeight_max="300dp"app:layout_constrainedHeight="true"
be sure to set the height wrap_content
Solution 2:
<View
android:id="@+id/view2"
android:layout_width="88dp"
android:layout_height="0dp"
android:background="#F44"
app:layout_constraintBottom_toTopOf="@+id/view"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintHeight_max="300dp"
/>
<View
android:id="@+id/view"
android:layout_width="88dp"
android:layout_height="150dp"
android:background="#690"
app:layout_constraintBottom_toTopOf="@+id/view3"
app:layout_constraintTop_toBottomOf="@+id/view2"
/>
<View
android:id="@+id/view3"
android:layout_width="88dp"
android:layout_height="150dp"
android:background="#93C"
app:layout_constraintBottom_toBottomOf="parent"
/>
Solution 3:
The issue could be that you can't have both those constraints set at the same time on the red view:
app:layout_constraintBottom_toTopOf="@+id/green"
app:layout_constraintTop_toBottomOf="@+id/appBarLayout"
If both those constraints are set, then the red view will be attached on top to the appBarLayout, and on the bottom to the green view, and this means that it will occupy all the space between those two views.
If you want to have the max height constraint be respected, you need to remove one of those two constraints. Which one should be removed depends on what kind of final result you are expecting.
OLD ANSWER
I think you should use android:maxHeight
instead of app:layout_constraintHeight_max
.
Post a Comment for "Constraintlayout Doesn't Respect Max Height"