How to have Scrollview grow with its contant up to certain point and then stop and be able to actually scroll contant from this point

33 views Asked by At

I'm trying to make a popup coming out from below, which can increase height to a certain point (guideline in percentage, 10%). The content may be larger than this size, so it needs to be scrollable.

So my layout is this:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/clContent"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/gl_top"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent=".1"
        />

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="@id/gl_top"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constrainedHeight="true"
        app:layout_constraintVertical_bias="1"
        >

        <ScrollView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            >

            <View
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:background="@android:color/black"
                />

        </ScrollView>

    </androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

And what actually happens is this: ScrollView have zero height. So my question is how to make popup with wrap_content layout height to scroll after it achieve its top point?

0

There are 0 answers