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
正常运行,您需要滚动子项来实现
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 :)
P.S.顺便提一句,我不知道您为什么要使用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屋!