ScrollingViewBehavior的ListView控件 [英] ScrollingViewBehavior for ListView
问题描述
我用两个活动 AppBarLayout
与工具栏
和 TabLayout
从支持库22。
I have two activities using AppBarLayout
with a Toolbar
and TabLayout
from support library 22.
两者的布局是pretty的相似:A 工具栏
上方,下方 TabLayout
,它下面的一个 ViewPager
含3 片段
秒。
The layout of both is pretty similar: A Toolbar
at the top, below it TabLayout
, below it a ViewPager
containing 3 Fragment
s.
第一个活动的片段
有一个 RecyclerView
,
第二项活动的片段
正在使用的ListView
代替。
The first activity's Fragment
has a RecyclerView
,
the second activity's Fragment
is using a ListView
instead.
从 https://github.com/chrisbanes/cheesesquare的滚动工具栏
例子采用做工精细的第一个活动的 RecyclerView
,但在与的ListView
。
我试图创建一个自定义的 ListViewScrollBehavior
扩展 AppBarLayout.ScrollingViewBehavior
,但至今没有运气。
该的TouchEvent
取值滚动的ListView
(垂直)时,传递到自定义类只为横向滚动,但不是。
I've tried created a custom ListViewScrollBehavior
that extends AppBarLayout.ScrollingViewBehavior
, but so far no luck.
The TouchEvent
s are passed to the custom class only for horizontal scrolling, but not when scrolling the ListView
(vertically).
任何方式使用 CoordinatorLayout
与的ListView
?
推荐答案
唯一的解决方案,使现在的工作就是用这样的:
The only solution to make it work now is to use this:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
listView.setNestedScrollingEnabled(true);
}
这显然只适用于棒棒糖。
It will obviously only work on Lollipop.
这篇关于ScrollingViewBehavior的ListView控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!