【发布时间】:2015-11-13 10:34:00
【问题描述】:
我在滚动/嵌套滚动视图中尝试了列表和回收器视图,列表的高度没有正确扩展。如果我硬编码列表的高度而不是它的工作原理,否则包装内容不起作用。 由于滚动视图中的列表视图和两个对象都具有滚动能力,我在互联网上进行了很多搜索,这就是为什么一个对象不让另一个对象滚动的原因。这就是为什么列表视图的高度不起作用的原因。我知道这是不好的做法,但我没有选择我的布局包含多个对象,如复选框和编辑文本。我也需要滚动其他对象。
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
xmlns-android="http-//schemas.android.com/apk/res/android"
xmlns-app="http-//schemas.android.com/apk/res-auto"
android-isScrollContainer="false"
android-layout_width="match_parent"
android-layout_height="match_parent"
android-layout_gravity="fill_vertical"
android-clipToPadding="false"
app-layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android-layout_width="match_parent"
android-layout_height="match_parent"
android-orientation="vertical"
android-paddingTop="1dp">
<ListView
android-id="@+id/list"
android-layout_width="fill_parent"
android-layout_height="match_parent"
android-divider="@null" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
【问题讨论】:
-
你需要给listView设置一个固定的高度,有什么问题?
-
我相信 NestedScrollView 中的 RecyclerView 应该可以工作,但您需要致电
recyclerView.setNestedScrollingEnabled(true)。 -
我可以完成“m vai”的陈述。 RecyclerView 与 CollapsingToolbar 结合使用似乎更加可靠。
-
列表中的项目是动态的,项目在运行时生成,这就是我无法修复高度的原因
-
我也试过recyclerview同样的结果
标签: android listview android-recyclerview android-scrollview