-1

I need to put a ListView inside ScrollBar. I know there is other question about this theme but the answers are very complex and bad.

The ListView doesn't show all its elements, only the first one.

The main structure of my relevant code:

<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                ....MORE ELEMENTS....
                <ListView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"

                    ></ListView>

            </LinearLayout>
        </ScrollView>
    </RelativeLayout>
gugolplex
  • 29
  • 5
  • Try to set layout_height="match_parent" in the scrollview and add "android:fillViewport=true" to the scroll view – guipivoto Oct 25 '19 at 01:32
  • duplicate https://stackoverflow.com/questions/18367522/android-list-view-inside-a-scroll-view – L2_Paver Oct 25 '19 at 01:50

1 Answers1

0

Put your ListView in a separate LinearLayout parent or you can add it in a separate .xml file according to your choice and add

 android:fillViewport="true"

in your scrollview, like this

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <!....MORE ELEMENTS....>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <ListView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

        </LinearLayout>

    </LinearLayout>

</ScrollView>