ScrollingViewBehavior的ListView控件 [英] ScrollingViewBehavior for ListView

查看:409
本文介绍了ScrollingViewBehavior的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 Fragments.

第一个活动的片段有一个 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 TouchEvents 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆