为什么更改 GestureOverlayView 的 StrokeType 会影响视图的标准行为?
我最近在我的应用程序中引入了多笔画手势。这是一个首选项,因此我在 Activity.OnCreate 中动态设置 StrokeType。我发现,如果动态设置 StrokeType,它会按以下方式更改 GestureOverlayView 的行为。
正常的行为是您绘制一个手势,并且绘制后它会保留在屏幕上。然而,当您动态更改笔画类型时,在屏幕上绘制的任何手势都会在 OnGestureEnded 事件触发后立即消失。我重新加载了示例 GesturesBuilder 应用程序,并确认如果您添加此处显示的第二行,它也会出现相同的问题:
GestureOverlayView overlay = (GestureOverlayView) findViewById(R.id.gestures_overlay);
overlay.setGestureStrokeType(GestureOverlayView.GESTURE_STROKE_TYPE_SINGLE);
overlay.addOnGestureListener(new GesturesProcessor());
}
Is this a bug in the Android Gestures Library and does people know a workaround?
请注意,这是在 HTC Magic 上发生的,因此也可能是手机问题。
I recently introduced multi-stroke gestures into my application. This is a preference so I set the StrokeType dynamically in Activity.OnCreate. What I have discovered is that if you set the StrokeType dynamically, it changes the behaviour of the GestureOverlayView in the following way.
The normal behaviour is that you draw a gesture and it stays on the screen after it is drawn. When you change the stroke type dynamically however, any gesture drawn on the screen disappears immediately after the OnGestureEnded event has fired. I reloaded the sample GesturesBuilder application and confirmed it has the same problem if you add the second line shown here:
GestureOverlayView overlay = (GestureOverlayView) findViewById(R.id.gestures_overlay);
overlay.setGestureStrokeType(GestureOverlayView.GESTURE_STROKE_TYPE_SINGLE);
overlay.addOnGestureListener(new GesturesProcessor());
}
Is this a bug in the Android gestures library and does anyone know a workaround?
Note that this is on an HTC Magic so it could also be a handset issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在手势叠加的 XML 文件中静态设置笔画类型。
由于 fadeOffset 设置为较低的数字,手势很快消失。如果您自己设置它,如上面所示,则需要经过一定的时间该手势才会消失。经过这一时间后,将调用 OnGestureEvent 或 OnGesturePerformedListener,具体取决于您使用的是哪一个。
You could set the stroke type statically in the XML file of the Gesture Overlay.
The gesture disappears quickly because the fadeOffset is set to a low number. If you set it yourself, like above, it will take that amount of time before the gesture dissapears. After this amount of time, the OnGestureEvent or OnGesturePerformedListener is called depending on which one you are using.