AppBarLayout 的嵌套 RecyclerView 问题 [英] Nested RecyclerView issue with AppBarLayout

查看:33
本文介绍了AppBarLayout 的嵌套 RecyclerView 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的活动包含一个由设计库 23.0.1 提供的 AppBarLayout,当我向上滚动时它会隐藏.我有一个 RecyclerView,每个子项也包含一个 RecyclerView,基本上是一个嵌套的 RecyclerView.

My activity contains an AppBarLayout provided by the design library 23.0.1, it hides when I scroll up. I have a RecyclerView with each child item containing a RecyclerView too, basically a nested RecyclerView going on.

我的问题是,当我触摸任何内部 RecyclerView 的子项并向上滚动时,AppBar 不会隐藏.但是,如果我将手指放在其他地方(不是内部 RecyclerView)并滚动,应用栏会向上滚动.为什么会这样?我什至尝试为内部回收器视图添加应用栏行为,但只有当我触摸其他地方并滚动时,应用栏才会向上滚动.

My issue is that when I touch on any of the inner RecyclerView's child and scroll up, the AppBar does not hide. However, if I place my finger somewhere else (not on the inner RecyclerView) and scroll, the app bar scrolls up just fine. Why is this happening? I even tried adding the appbar behavior for the inner recycler view, yet the app bar would only scroll up when I touch somewhere else and scroll.

注意:内部 recyclerview 有一组固定的项目,这些项目始终可见,基本上,recyclerview 内没有滚动.

Note: the inner recyclerview has a fixed set of items that would be visible at all times, basically, there is no scrolling within the recyclerview.

有一个类似的问题和提供的解决方案是拦截内部回收器视图的触摸并将其传递给父回收器视图.但这会禁用内部回收器视图中子项的点击事件,我不希望那样.

There is a similar question and a provided solution would be to intercept the touch of the inner recyclerview and pass it to the parent recycler view. But this disables the click events of the children in the inner recycler view, I do not want that.

推荐答案

对于内部回收器视图,您需要将嵌套滚动标志设置为 false.

You need to set the nested scrolling flag to false for inner recycler views.

mSomeInnerRecyclerView.setNestedScrollingEnabled(false);

mSomeInnerRecyclerView.setNestedScrollingEnabled(false);

这篇关于AppBarLayout 的嵌套 RecyclerView 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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