A Question For Anyone Experienced With Android And Xml To Explain A Mystery
Solution 1:
The issue comes about because app:layout_constrainedHeight="true"
is specified for both of the include files. Only the first app:layout_constrainedHeight="true"
is honored and the second is not.
Here is a simplified layout to demonstrate the problem:
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/decoder_text_to_morse_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/include_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/red"
android:hint="Text"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toTopOf="@+id/include_morse"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/include_morse"
layout="@layout/layout_edit_text_morse"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/darkGreen"
android:hint="Morse"
android:inputType="textMultiLine"
app:layout_constrainedHeight="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/include_text" />
</androidx.constraintlayout.widget.ConstraintLayout>
Since only the first view with app:layout_constrainedHeight="true"
is honored, then the order will matter. You can try various combinations of this flag in the above layout to see what I mean. (ConstraintLayout version 2.0.4 is used.)
I would expect both flags to be honored instead of just one, but this is one of those cases where it is difficult to discern whether it is a defect or just a limitation.
Setting app:layout_constrainedHeight="false"
for both views and relying on the vertical chain to do its job works a little better, but the layout slides a little beneath the status and navigation bars on the emulator.
Post a Comment for "A Question For Anyone Experienced With Android And Xml To Explain A Mystery"