ViewPager在ListView - 如何锁定滚动轴? [英] ViewPager in a ListView - how to lock the scrolling axis?

查看:200
本文介绍了ViewPager在ListView - 如何锁定滚动轴?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ViewPager部件一个ListView的每一排。这提供了一种架状的UI,所以用户可以滚动周围寻找一个货架垂直,然后水平滚动当中一个书架上的内容。这工作。

I have a ViewPager widget in every row of a ListView. This provides a shelf-like UI, so the user can scroll around searching for a shelf vertically, and then scroll horizontally amongst the contents of a shelf. This works.

但滚动的经验是可怕的:如果我开始拖棚的ViewPager,水平滚动它,并意外地拖动了一下向上/向下,然后在ListView陷阱这一拖的动作,并开始垂直滚动,结束了我横向拖动。在这种状态下,拖拽动作不会回归到ViewPager,ListView中有它,这就是它。我要开始另一种拖拉动作,再次影响ViewPager。所以我想在ListView有precedence在这些情况下。

But the scrolling experience is terrible: if I start to drag a shelf's ViewPager, scroll it horizontally, and accidentally drag a bit upwards/downwards, then the ListView "traps" this dragging action, and start to scroll vertically, ending my horizontal drag. In this state, the drag action won't "return" to the ViewPager, the ListView has it, and that's it. I have to start another drag action to affect the ViewPager again. So I guess the ListView has precedence in these cases.

这怎么能解决吗?我想实现完全相反:如果一个列表行内ViewPager开始反应到水平阻力,那么它应该陷阱的行动,而这种阻力应该停止影响的ListView,无论用户如何移动他/她的手指垂直。可以这样做?

How can this be fixed? I'd like to achieve the exact opposite: If the ViewPager inside a list row starts reacting to a horizontal drag, then it should trap that action, and this drag should stop affecting the ListView, no matter how the user moves his/her finger vertically. Can this be done?

推荐答案

我发现在<一个一个的解决方案href="http://stackoverflow.com/questions/2646028/android-horizontalscrollview-within-scrollview-touch-handling">this线。这里的问题是正确处理触摸事件的定期滚动型内Horizo​​ntalScrollView,但解决这一问题似乎适用于这一个了。

I've found a solution in this thread. There the problem is to handle touch events properly for a HorizontalScrollView inside a regular ScrollView, but the solution to that problem seems to apply to this one too.

这篇关于ViewPager在ListView - 如何锁定滚动轴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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