Following snippet from my layout xml:

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_constraintTop_toBottomOf="@id/fragment_home_info_card_car_position"
            android:maxHeight="300dp"
            >

                <androidx.core.widget.NestedScrollView        
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:elevation="10dp">

                    <include
                        android:id="@+id/fragment_home_filter_chips"
                        layout="@layout/selection_chips"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="4dp" />

                </androidx.core.widget.NestedScrollView>


        </androidx.constraintlayout.widget.ConstraintLayout>

wraps the content correctly, it wraps the include and doesn't exceed the height. But the content of the include get cut off approx 100dp down when scrolling. This may be because there is a rather slow fill of the include (in the background with a lifeCyclescope coroutine).

In my effort to overcome this I just constraint the height to a fixed value like this:

<androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="300dp"
            app:layout_constraintTop_toBottomOf="@id/fragment_home_info_card_car_position"
            
            >
...

Now suddenly the height of the include was correctly justified, and I could scroll down the bottom of it, but of course not constrained to the content if it was smaller than 300dp...

My question is, how do I constraint the height as in the first snippet and is sure that my include is fully expanded (viewed expanded inside the scrollview) ?

Do maxHeight do some "magic" that isn't quite well here ?

0

There are 0 best solutions below