重叠的滚动视图
我有一个问题...我在绝对布局中有两个滚动视图。换句话说,它们是全屏的,并且彼此重叠,
顶部滚动视图是水平滚动视图,底部滚动视图是垂直滚动视图。
当我水平滚动时,我希望顶部滚动,当我垂直滚动时,我希望底部滚动。
但我的问题是水平滚动视图接受所有滚动事件,因此底部的滚动视图永远不会收到滚动事件...
我该如何解决这个问题?
提前致谢!
I have a problem... I have two scrollviews in a absolutelayout. in other words they are fullscreen and laying over each other
the top scrollview is a horizontal scrolling one and the bottom one is a vertical scrolling scrollview.
when I scroll horizontal I want the top one to scroll and when I scroll vertical I want the bottom one to scroll.
but my problem is that the horizontal scrollview takes all scroll events so the bottom one never receives a scroll event...
How can I resolve this?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
把它们嵌套起来怎么样?您可以通过填充和边距使其在视觉上看起来相同,此外您还可以控制哪个视图处理触摸。
我不确定你是否可以说一个滚动视图应该只处理水平方向,而另一个滚动视图应该只处理垂直方向 - 可能不是。但是您可以重写 onTouchEvent 和 onInterceptTouchEvent 来定义您需要的任何行为! (查看 http://developer.android.com/reference/android/view/ GestureDetector.html )
例如,如果您希望父滚动视图仅处理垂直滚动,而子滚动视图处理水平滚动,则应该
}
或类似的内容。这不是你应该做什么,但你明白了。
How about nesting them? You can make it look visually the same, via paddings and margins and furthermore you can control which view handles the touches.
I am not sure if you can say that one scroll view should handle only horizontal and the other to handle only vertical - probably not. But you can override onTouchEvent and onInterceptTouchEvent in both to define whatever behaviour you need! (Check out http://developer.android.com/reference/android/view/GestureDetector.html )
For example, if you want the parent scroll view to handle only vertical scroll, and the child the handle horizontal, you should
}
Or something like that. It is not exaclty what you should do, but you get the idea.
您可能需要为此实现自定义控件。您的自定义控件需要一个 Scroller 类。您也可以下载 ScrollView类的源码并修改为双向。
并且不要将可滚动的东西放入其他可滚动的东西中 - 它们往往会争夺触摸事件。
You'll probably need to implement a custom control for this. You'll need a Scroller class for your custom control. Also you can download source code for ScrollView class and modify it to be bidirectional.
And don't put scrollable things into other scrollable things - they tend to fight over touch events.