ViewPager inside ViewPager.How to scroll parent pager horizontally instead of scrolling child, but keep child pager vertical scroll?

允我心安 提交于 2019-12-10 18:03:26

问题


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.

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?


回答1:


The solution was easier than I expected.

Just override canScrollHorizontally in child ViewPager and return false.



来源:https://stackoverflow.com/questions/33463804/viewpager-inside-viewpager-how-to-scroll-parent-pager-horizontally-instead-of-sc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!