java - ViewPager嵌套ViewPager?
巴扎黑
巴扎黑 2017-04-18 10:50:11
0
3
518

在一个Fragment中有一个viewpager包含了三个子fragment,其中在包含的第一个子fragment中,也有一个子viewpager,如何让那个子viewpager禁止横向滑动,但是可以通过viewpager.setCurrentItem()来跳转,同时能让子viewpager里面包含的控件能够响应竖直滑动和点击事件。

巴扎黑
巴扎黑

reply all(3)
阿神

Inherit the ViewPager class, and override the onTouchEvent and onInterceptTouchEvent methods, directly return false in the method;

迷茫

Try the method ViewPager.canScrollHorizontally(boolean which). I haven’t tried it. I can’t say whether there is a sliding conflict problem.

If so, you can choose to rewrite onTouchEvent yourself, or give up using ViewPager and switch different fragments to achieve your purpose.

黄舟

如 @周文超 所说.

传送门:

  • How do disable paging by swiping with finger in ViewPager but still be able to swipe programmatically?

  • How to disable or enable viewpager swiping in android

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template