垂直和水平的手势在安卓 [英] Vertical and Horizontal gestures in Android
问题描述
我想我的GestureOverlayView同时检测纯水平和垂直的姿态。
I would like my GestureOverlayView to detect both purely horizontal as well as vertical gestures.
从<一个href="http://android-developers.blogspot.com/2009/10/gestures-on-android-16.html">http://android-developers.blogspot.com/2009/10/gestures-on-android-16.html
取向:表示的意见的滚动方向下方。在这种情况下,列表中垂直滚动,这意味着任何水平手势(像action_delete)可以立即识别为手势与一个垂直行程开始必须包含手势。至少一个水平分量被识别。换句话说,一个简单的垂直线不能被识别为手势,因为它将与列表的滚动发生冲突。
"orientation: indicates the scroll orientation of the views underneath. In this case the list scrolls vertically, which means that any horizontal gestures (like action_delete) can immediately be recognized as a gesture. Gestures that start with a vertical stroke must contain at least one horizontal component to be recognized. In other words, a simple vertical line cannot be recognized as a gesture since it would conflict with the list's scrolling."
看起来像一个catch-22,如果机器人:方向设置为垂直的,我只能有水平挥笔,如果机器人:方向设置为横向,我只能垂直刷卡。 我怎样才能解决这个要求得到什么呢?
Seems like a catch-22, if the android:orientation is set to vertical, I can only have horizontal swipes, and if the android:orientation is set to horizontal, I can only have vertical swipes. How can I get around this requirement?
推荐答案
所有你需要做的,是设置GestureStrokeAngleThreshold的值接近90(我用90F)
All you have to do, is set the GestureStrokeAngleThreshold to a value closer to 90 (I used 90f)
角度threashold的默认值为40.0f,因为其中的简单的垂直的手势将跳过
The default value of the angle threashold is 40.0f because of which your simple vertical gestures would be skipped
这篇关于垂直和水平的手势在安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!