How to fix overlapping expandable list view scrolling problem inside constraint layout with other child views?

Viewed 344

I need to build Grofers like home page with all views like viewpager, recyclerview, expandable list view and linear layouts with frame layout and most importantly add scrolling to each view. But the expandable list view height is not acquiring according to group elements. Its showing only one group view height and scrolling all views inside that particular height. I tried scroll view, Nested scroll view, Linear layout but nothing fits the scenario.

<androidx.constraintlayout.widget.ConstraintLayout
        android:orientation="vertical"
        android:id="@+id/ll_home"
        app:layout_constrainedHeight="true"
        app:layout_constrainedWidth="true"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:id="@+id/linearLayout3"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp"
            android:background="@color/colorOrange"
            app:layout_constrainedWidth="true"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="@id/linearLayout3"
            app:layout_constraintBottom_toTopOf="@id/expandablelistview"
            app:layout_constraintHeight_default="wrap">
        </RelativeLayout>
        
        <ExpandableListView
            android:id="@+id/expandablelistview"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:layout_alignParentTop="true"
            android:layout_marginTop="8dp"
            android:background="@color/colorBlue"
            android:groupIndicator="@null"
            android:layout_below="@id/linearLayout3" />

</androidx.constraintlayout.widget.ConstraintLayout>

1 Answers
<androidx.constraintlayout.widget.ConstraintLayout
        android:orientation="vertical"
        android:id="@+id/ll_home"
        app:layout_constrainedHeight="true"
        app:layout_constrainedWidth="true"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:id="@+id/linearLayout3"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp"
            android:background="@color/colorOrange"
            app:layout_constrainedWidth="true"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="@id/linearLayout3"
            app:layout_constraintBottom_toTopOf="@id/expandablelistview"
            app:layout_constraintHeight_default="wrap">
        </RelativeLayout>

        <ExpandableListView
            android:id="@+id/expandablelistview"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            app:layout_constraintTop_toBottomOf="@+id/linearLayout3"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            android:layout_alignParentTop="true"
            android:layout_marginTop="8dp"
            android:background="@color/colorBlue"
            android:groupIndicator="@null"
            android:layout_below="@id/linearLayout3" />

</androidx.constraintlayout.widget.ConstraintLayout>
Related