问题描述
我有一个父级ViewPager
,其每个页面都包含一个子级ViewPager
.子级ViewPager
可以包含ListView
或垂直的ScrollView
.我想从子级ViewPager
到父级ViewPager
传递水平滚动,但要保持子级ViewPager
垂直滚动.
I have a parent ViewPager
, each page of which contains a child ViewPager
.Child ViewPager
may contain a ListView
or a vertical ScrollView
.I want to pass horizontal scroll from child ViewPager
to parent ViewPager
, but want to keep child ViewPager
scrollable vertical.
在子级ViewPager中覆盖dispatchTouchEvent(MotionEvent event)
并返回false
有助于将运动事件传递给父级ViewPager,但是如何使子级ViewPager
中的ListView
和ScrollView
保持可滚动状态?
Overriding dispatchTouchEvent(MotionEvent event)
in child ViewPager and returning false
helps to pass motion events to parent ViewPager, but how to keep ListView
and ScrollView
in child ViewPager
scrollable?
推荐答案
该解决方案比我想象的要容易.
The solution was easier than I expected.
只需在子级ViewPager中覆盖canScrollHorizontally
并返回false.
Just override canScrollHorizontally
in child ViewPager and return false.
这篇关于ViewPager内的ViewPager.如何水平滚动父寻呼机而不是滚动子级,但保持子寻呼机垂直滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!