为scrollview而不是listview启用滚动

时间:2014-09-27 07:29:42

标签: android listview android-listview android-scrollview android-scroll

我在ScrollView中有一个ListView - 但我的问题是我不希望Listview滚动,而是我希望listview完全展开,只需向上和向下滚动ScrollView以查看项目列表显示。有人能重新找到解决方案吗?

这是我的布局:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_horizontal"
    >


        <ListView
            android:id="@+id/user_list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:divider="@null"
            android:visibility="gone" />

</ScrollView>

P.S。我知道这是不好的做法,但无论如何我都需要这个东西

3 个答案:

答案 0 :(得分:0)

在你的scrollview android中设置这个属性:fillViewport =&#34; true&#34;它会起作用

答案 1 :(得分:0)

两个滚动视图不能在彼此内部。 请点击以下链接: ListView inside ScrollView is not scrolling on Android

答案 2 :(得分:0)

您可以考虑this。但ListView的高度必须是硬编码的,它的回收率会略微偏离您的要求。但正如你所提到的那样,没有回收的ListView不是一个好习惯。因此,尝试使用上述链接中描述的回收来实现。