【发布时间】:2016-04-13 08:49:55
【问题描述】:
我在 NestedScrollView 中使用 ListView。 列表展开以匹配父级,但现在没有滚动
这是我的布局:
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:fillViewport="true"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:id="@+id/workExperienceListLV"
android:divider="@null"
android:listSelector="@android:color/transparent"
android:dividerHeight="0dp"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
这条线没有帮助:
android:fillViewport="true"
感谢您的帮助!
【问题讨论】:
-
使用recyclerview,listview不能使用nestedscrolling功能。
-
@oguzhand 有什么办法可以让它与 listView 一起工作吗?
-
因为滚动在 ListView 中可用,所以不能使用 ScrollView 包装它。所以改为将 layout_height 设置为一些 dp 说它 200dp,然后布局将滚动。如果您在该布局中仅使用 ListView,则不必将 NestedScrollView 包装起来。
-
RecyclerView 和 NestedScrollView 是为协同工作而设计的,ListView 是一个旧的小部件,不支持嵌套滚动。您可以管理它,但您的回收结构将不起作用(这是不合逻辑的)。我几个月都没有使用 Listview。只需使用 RecyclerView。
-
好的,我将切换到 RecyclerView,谢谢!你真的帮了我。 @oguzhand
标签: android listview nestedscrollview