ViewPager内的ViewPager

ViewPager内的ViewPager

本文介绍了ViewPager内的ViewPager.如何水平滚动父寻呼机而不是滚动子级,但保持子寻呼机垂直滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个父级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中的ListViewScrollView保持可滚动状态?

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.如何水平滚动父寻呼机而不是滚动子级,但保持子寻呼机垂直滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 08:23