Why would changing the StrokeType of a GestureOverlayView affect the standard behaviour of the view?
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.
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.
精彩评论