ListView 未在 NestedScrollView 内扩展 [英] ListView not expanding inside NestedScrollView
问题描述
我在我的活动页面中使用了 CoordinatorLayout
.在应用栏下方有 ListView
.但是当我使用 ListView
而不是 NestedScrollView
时它不起作用.如果我将 ListView
放在 NestedScrollView
中,ListView
不会扩展
I am using CoordinatorLayout
in my activity page. In that there is ListView
below the app bar. But its not working when I use ListView
instead of NestedScrollView
. And if I put ListView
inside NestedScrollView
, ListView
is not expanding
推荐答案
要使 CoordinatorLayout
正常工作,您需要滚动子项来实现 NestedScrollingChild.这些类是 NestedScrollView
和 RecyclerView
.
For the CoordinatorLayout
to work properly you need the scrolling child to implement NestedScrollingChild. Such classes are NestedScrollView
and RecyclerView
.
简而言之 - 只需为您的滚动内容使用 RecyclerView
即可正常工作:)
To say it short - just use a RecyclerView
for your scrolling content and it'll work correctly :)
附言作为旁注,我看不出您再使用 ListView
的理由.我知道这是一种习惯,而且设置起来更容易(因为你已经做过很多次了),但无论如何使用 RecyclerView
是推荐的方法.
P.S. As a side note, I don't see a reason why you'd use a ListView
anymore. I know it's a habit and it's easier to setup (because you've done it many times), but using a RecyclerView
is the recommended way anyways.
这篇关于ListView 未在 NestedScrollView 内扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!