Как исправить ListView внутри ScrollView? - PullRequest
0 голосов
/ 25 октября 2019

Мне нужно поместить ListView внутри ScrollBar. Я знаю, что есть другой вопрос по этой теме, но ответы очень сложные и плохие.

ListView не показывает все свои элементы, только первый.

Основная структура моегосоответствующий код:

<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>

1 Ответ

0 голосов
/ 25 октября 2019

Поместите ListView в отдельного LinearLayout родителя, или вы можете добавить его в отдельный XML-файл по вашему выбору и добавить

 android:fillViewport="true"

в ваше прокручиваемое изображение, например,

<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>

...