public class

GestureOverlayView

extends FrameLayout
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ android.gesture.GestureOverlayView

Class Overview

A transparent overlay for gesture input that can be placed on top of other widgets or contain other widgets.

Summary

Nested Classes
interface GestureOverlayView.OnGestureListener  
interface GestureOverlayView.OnGesturePerformedListener  
interface GestureOverlayView.OnGesturingListener  
XML Attributes
Attribute Name Related Method Description
android:eventsInterceptionEnabled Defines whether the overlay should intercept the motion events when a gesture is recognized. 
android:fadeDuration Duration, in milliseconds, of the fade out effect after the user is done drawing a gesture. 
android:fadeEnabled Defines whether the gesture will automatically fade out after being recognized. 
android:fadeOffset Time, in milliseconds, to wait before the gesture fades out after the user is done drawing it. 
android:gestureColor Color used to draw a gesture. 
android:gestureStrokeAngleThreshold Minimum curve angle a stroke must contain before it is recognized as a gesture. 
android:gestureStrokeLengthThreshold Minimum length of a stroke before it is recognized as a gesture. 
android:gestureStrokeSquarenessThreshold Squareness threshold of a stroke before it is recognized as a gesture. 
android:gestureStrokeType Defines the type of strokes that define a gesture. 
android:gestureStrokeWidth Width of the stroke used to draw the gesture. 
android:orientation Indicates whether horizontal (when the orientation is vertical) or vertical (when orientation is horizontal) strokes automatically define a gesture. 
android:uncertainGestureColor Color used to draw the user's strokes until we are sure it's a gesture. 
[Expand]
Inherited XML Attributes
From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
Constants
int GESTURE_STROKE_TYPE_MULTIPLE
int GESTURE_STROKE_TYPE_SINGLE
int ORIENTATION_HORIZONTAL
int ORIENTATION_VERTICAL
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
GestureOverlayView(Context context)
GestureOverlayView(Context context, AttributeSet attrs)
GestureOverlayView(Context context, AttributeSet attrs, int defStyle)
Public Methods
void addOnGestureListener(GestureOverlayView.OnGestureListener listener)
void addOnGesturePerformedListener(GestureOverlayView.OnGesturePerformedListener listener)
void addOnGesturingListener(GestureOverlayView.OnGesturingListener listener)
void cancelClearAnimation()
void cancelGesture()
void clear(boolean animated)
boolean dispatchTouchEvent(MotionEvent event)
Pass the touch screen motion event down to the target view, or this view if it is the target.
void draw(Canvas canvas)
Manually render this view (and all of its children) to the given Canvas.
ArrayList<GesturePoint> getCurrentStroke()
long getFadeOffset()
Gesture getGesture()
int getGestureColor()
Path getGesturePath(Path path)
Path getGesturePath()
float getGestureStrokeAngleThreshold()
float getGestureStrokeLengthThreshold()
float getGestureStrokeSquarenessTreshold()
int getGestureStrokeType()
float getGestureStrokeWidth()
int getOrientation()
int getUncertainGestureColor()
boolean isEventsInterceptionEnabled()
boolean isFadeEnabled()
boolean isGestureVisible()
boolean isGesturing()
void removeAllOnGestureListeners()
void removeAllOnGesturePerformedListeners()
void removeAllOnGesturingListeners()
void removeOnGestureListener(GestureOverlayView.OnGestureListener listener)
void removeOnGesturePerformedListener(GestureOverlayView.OnGesturePerformedListener listener)
void removeOnGesturingListener(GestureOverlayView.OnGesturingListener listener)
void setEventsInterceptionEnabled(boolean enabled)
void setFadeEnabled(boolean fadeEnabled)
void setFadeOffset(long fadeOffset)
void setGesture(Gesture gesture)
void setGestureColor(int color)
void setGestureStrokeAngleThreshold(float gestureStrokeAngleThreshold)
void setGestureStrokeLengthThreshold(float gestureStrokeLengthThreshold)
void setGestureStrokeSquarenessTreshold(float gestureStrokeSquarenessTreshold)
void setGestureStrokeType(int gestureStrokeType)
void setGestureStrokeWidth(float gestureStrokeWidth)
void setGestureVisible(boolean visible)
void setOrientation(int orientation)
void setUncertainGestureColor(int color)
Protected Methods
void onDetachedFromWindow()
This is called when the view is detached from a window.
[Expand]
Inherited Methods
From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource

XML Attributes

android:eventsInterceptionEnabled

Since: API Level

Defines whether the overlay should intercept the motion events when a gesture is recognized.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol eventsInterceptionEnabled.

Related Methods

android:fadeDuration

Since: API Level

Duration, in milliseconds, of the fade out effect after the user is done drawing a gesture.

Must be an integer value, such as "100".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol fadeDuration.

Related Methods

android:fadeEnabled

Since: API Level

Defines whether the gesture will automatically fade out after being recognized.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol fadeEnabled.

Related Methods

android:fadeOffset

Since: API Level

Time, in milliseconds, to wait before the gesture fades out after the user is done drawing it.

Must be an integer value, such as "100".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol fadeOffset.

Related Methods

android:gestureColor

Since: API Level

Color used to draw a gesture.

Must be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol gestureColor.

Related Methods

android:gestureStrokeAngleThreshold

Since: API Level

Minimum curve angle a stroke must contain before it is recognized as a gesture.

Must be a floating point value, such as "1.2".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol gestureStrokeAngleThreshold.

Related Methods

android:gestureStrokeLengthThreshold

Since: API Level

Minimum length of a stroke before it is recognized as a gesture.

Must be a floating point value, such as "1.2".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol gestureStrokeLengthThreshold.

Related Methods

android:gestureStrokeSquarenessThreshold

Since: API Level

Squareness threshold of a stroke before it is recognized as a gesture.

Must be a floating point value, such as "1.2".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol gestureStrokeSquarenessThreshold.

Related Methods

android:gestureStrokeType

Since: API Level

Defines the type of strokes that define a gesture.

Must be one of the following constant values.

ConstantValueDescription
single0 A gesture is made of only one stroke.
multiple1 A gesture is made of multiple strokes.

This corresponds to the global attribute resource symbol gestureStrokeType.

Related Methods

android:gestureStrokeWidth

Since: API Level

Width of the stroke used to draw the gesture.

Must be a floating point value, such as "1.2".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol gestureStrokeWidth.

Related Methods

android:orientation

Since: API Level

Indicates whether horizontal (when the orientation is vertical) or vertical (when orientation is horizontal) strokes automatically define a gesture.

Must be one of the following constant values.

ConstantValueDescription
horizontal0 Defines an horizontal widget.
vertical1 Defines a vertical widget.

This corresponds to the global attribute resource symbol orientation.

Related Methods

android:uncertainGestureColor

Since: API Level

Color used to draw the user's strokes until we are sure it's a gesture.

Must be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol uncertainGestureColor.

Related Methods

Constants

public static final int GESTURE_STROKE_TYPE_MULTIPLE

Since: API Level 4

Constant Value: 1 (0x00000001)

public static final int GESTURE_STROKE_TYPE_SINGLE

Since: API Level 4

Constant Value: 0 (0x00000000)

public static final int ORIENTATION_HORIZONTAL

Since: API Level 4

Constant Value: 0 (0x00000000)

public static final int ORIENTATION_VERTICAL

Since: API Level 4

Constant Value: 1 (0x00000001)

Public Constructors

public GestureOverlayView (Context context)

Since: API Level 4

public GestureOverlayView (Context context, AttributeSet attrs)

Since: API Level 4

public GestureOverlayView (Context context, AttributeSet attrs, int defStyle)

Since: API Level 4

Public Methods

public void addOnGestureListener (GestureOverlayView.OnGestureListener listener)

Since: API Level 4

public void addOnGesturePerformedListener (GestureOverlayView.OnGesturePerformedListener listener)

Since: API Level 4

public void addOnGesturingListener (GestureOverlayView.OnGesturingListener listener)

Since: API Level 4

public void cancelClearAnimation ()

Since: API Level 4

public void cancelGesture ()

Since: API Level 4

public void clear (boolean animated)

Since: API Level 4

public boolean dispatchTouchEvent (MotionEvent event)

Since: API Level 4

Pass the touch screen motion event down to the target view, or this view if it is the target.

Parameters
event The motion event to be dispatched.
Returns
  • True if the event was handled by the view, false otherwise.

public void draw (Canvas canvas)

Since: API Level 4

Manually render this view (and all of its children) to the given Canvas. The view must have already done a full layout before this function is called. When implementing a view, implement onDraw(Canvas) instead of overriding this method. If you do need to override this method, call the superclass version.

Parameters
canvas The Canvas to which the View is rendered.

public ArrayList<GesturePoint> getCurrentStroke ()

Since: API Level 4

public long getFadeOffset ()

Since: API Level 4

public Gesture getGesture ()

Since: API Level 4

public int getGestureColor ()

Since: API Level 4

public Path getGesturePath (Path path)

Since: API Level 4

public Path getGesturePath ()

Since: API Level 4

public float getGestureStrokeAngleThreshold ()

Since: API Level 4

public float getGestureStrokeLengthThreshold ()

Since: API Level 4

public float getGestureStrokeSquarenessTreshold ()

Since: API Level 4

public int getGestureStrokeType ()

Since: API Level 4

public float getGestureStrokeWidth ()

Since: API Level 4

public int getOrientation ()

Since: API Level 4

public int getUncertainGestureColor ()

Since: API Level 4

public boolean isEventsInterceptionEnabled ()

Since: API Level 4

public boolean isFadeEnabled ()

Since: API Level 4

public boolean isGestureVisible ()

Since: API Level 4

public boolean isGesturing ()

Since: API Level 4

public void removeAllOnGestureListeners ()

Since: API Level 4

public void removeAllOnGesturePerformedListeners ()

Since: API Level 4

public void removeAllOnGesturingListeners ()

Since: API Level 4

public void removeOnGestureListener (GestureOverlayView.OnGestureListener listener)

Since: API Level 4

public void removeOnGesturePerformedListener (GestureOverlayView.OnGesturePerformedListener listener)

Since: API Level 4

public void removeOnGesturingListener (GestureOverlayView.OnGesturingListener listener)

Since: API Level 4

public void setEventsInterceptionEnabled (boolean enabled)

Since: API Level 4

public void setFadeEnabled (boolean fadeEnabled)

Since: API Level 4

public void setFadeOffset (long fadeOffset)

Since: API Level 4

public void setGesture (Gesture gesture)

Since: API Level 4

public void setGestureColor (int color)

Since: API Level 4

public void setGestureStrokeAngleThreshold (float gestureStrokeAngleThreshold)

Since: API Level 4

public void setGestureStrokeLengthThreshold (float gestureStrokeLengthThreshold)

Since: API Level 4

public void setGestureStrokeSquarenessTreshold (float gestureStrokeSquarenessTreshold)

Since: API Level 4

public void setGestureStrokeType (int gestureStrokeType)

Since: API Level 4

public void setGestureStrokeWidth (float gestureStrokeWidth)

Since: API Level 4

public void setGestureVisible (boolean visible)

Since: API Level 4

public void setOrientation (int orientation)

Since: API Level 4

public void setUncertainGestureColor (int color)

Since: API Level 4

Protected Methods

protected void onDetachedFromWindow ()

Since: API Level 4

This is called when the view is detached from a window. At this point it no longer has a surface for drawing.