Android ViewPager2,其中包含一个recyclerview的片段无法滚动 [英] Android ViewPager2 with fragment containing a recyclerview not scrolling

查看:863
本文介绍了Android ViewPager2,其中包含一个recyclerview的片段无法滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将ViewPager2与FragmentStateAdapter绑定在一起.我的每个片段都有3个垂直放置的回收站视图.问题是我无法滚动片段中的回收站视图,而且当我尝试垂直滚动内容时,视图分页器会更改选项卡.该如何解决?

I'm using ViewPager2 with FragmentStateAdapter to bind fragments. Each of my fragment has 3 recycler views laid out vertically. The problem is I'm not able to scroll the recycler view inside the fragments and also when I try to scroll the content vertically, the view pager changes tabs. How to fix this?

推荐答案

实际上ViewPager2不支持嵌套的Scrollable元素,因此,要在具有相同方向的ViewPager2对象内支持滚动视图,必须调用requestDisallowInterceptTouchEvent()或包装您在

Actually ViewPager2 Doesn't support nested Scrollable elements, So to support a scroll view inside a ViewPager2 object with the same orientation, you must call requestDisallowInterceptTouchEvent() or wrap your nested scrolling view inside this class.

这篇关于Android ViewPager2,其中包含一个recyclerview的片段无法滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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