首页 > 解决方案 > 具有多个 ListView 的嵌套 ScrollView 不滚动

问题描述

我只希望我的嵌套滚动视图滚动,我不希望列表滚动。由于某种原因,滚动视图不滚动。我查看了与嵌套滚动视图、滚动视图和列表视图相关的多个帖子,但没有一个解决方案有帮助。滚动视图不起作用很奇怪,我不确定我是否遗漏了什么。此外,我的列表视图具有动态高度。

这是我的代码:

<android.support.v4.widget.NestedScrollView
    android:id="@+id/ns_scroll"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

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

        <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/grey"
        android:orientation="vertical">

        <TextView
            style="@style/customFontStyleBook"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:padding="5dp"
            android:text="Heading 1"
            android:textColor="#000"
            android:textStyle="bold"/>


        <ListView
            android:id="@+id/ll1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/grey"
        android:orientation="vertical">

        <TextView
            style="@style/customFontStyleBook"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:padding="5dp"
            android:text="Heading 2"
            android:textColor="#000"
            android:textStyle="bold"/>

        <ListView
            android:id="@+id/ll2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

            </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/grey"
        android:orientation="vertical">

        <TextView
            style="@style/customFontStyleBook"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:padding="5dp"
            android:text="Heading 3"
            android:textStyle="bold"
            android:textColor="#000" />

        <ListView
            android:id="@+id/ll3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </LinearLayout>

    </LinearLayout>
 </android.support.v4.widget.NestedScrollView>

标签: androidlistviewandroid-listviewandroid-scrollviewnestedscrollview

解决方案


推荐阅读