为什么更改 GestureOverlayView 的 StrokeType 会影​​响视图的标准行为?

发布于 2024-09-01 18:34:06 字数 672 浏览 7 评论 0原文

我最近在我的应用程序中引入了多笔画手势。这是一个首选项,因此我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

洛阳烟雨空心柳 2024-09-08 18:34:06

您可以在手势叠加的 XML 文件中静态设置笔画类型。

<android.gesture.GestureOverlayView
android:id="@+id/gestures_alpha"
android:layout_width="fill_parent" 
android:layout_height="0dip"
android:layout_weight="1.0" 
android:gestureStrokeType="multiple"
android:fadeOffset="1000"
/>

由于 fadeOffset 设置为较低的数字,手势很快消失。如果您自己设置它,如上面所示,则需要经过一定的时间该手势才会消失。经过这一时间后,将调用 OnGestureEvent 或 OnGesturePerformedListener,具体取决于您使用的是哪一个。

You could set the stroke type statically in the XML file of the Gesture Overlay.

<android.gesture.GestureOverlayView
android:id="@+id/gestures_alpha"
android:layout_width="fill_parent" 
android:layout_height="0dip"
android:layout_weight="1.0" 
android:gestureStrokeType="multiple"
android:fadeOffset="1000"
/>

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文