Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
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

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

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

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

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

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

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

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

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

Defines the type of strokes that define a gesture.

Must be one of the following constant values.

Constant Value Description
single 0 A gesture is made of only one stroke.
multiple 1 A gesture is made of multiple strokes.

This corresponds to the global attribute resource symbol gestureStrokeType .

Related Methods

android:gestureStrokeWidth

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

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.

Constant Value Description
horizontal 0 Defines an horizontal widget.
vertical 1 Defines a vertical widget.

This corresponds to the global attribute resource symbol orientation .

Related Methods

android:uncertainGestureColor

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

Added in API level 4

Constant Value: 1 (0x00000001)

public static final int GESTURE_STROKE_TYPE_SINGLE

Added in API level 4

Constant Value: 0 (0x00000000)

public static final int ORIENTATION_HORIZONTAL

Added in API level 4

Constant Value: 0 (0x00000000)

public static final int ORIENTATION_VERTICAL

Added in API level 4

Constant Value: 1 (0x00000001)

Public Constructors

public GestureOverlayView ( Context context)

Added in API level 4

public GestureOverlayView ( Context context, AttributeSet attrs)

Added in API level 4

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

Added in API level 4

Public Methods

public void addOnGestureListener ( GestureOverlayView.OnGestureListener listener)

Added in API level 4

public void addOnGesturePerformedListener ( GestureOverlayView.OnGesturePerformedListener listener)

Added in API level 4

public void addOnGesturingListener ( GestureOverlayView.OnGesturingListener listener)

Added in API level 4

public void cancelClearAnimation ()

Added in API level 4

public void cancelGesture ()

Added in API level 4

public void clear (boolean animated)

Added in API level 4

public boolean dispatchTouchEvent ( MotionEvent event)

Added in 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)

Added in 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(android.graphics.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 ()

Added in API level 4

public long getFadeOffset ()

Added in API level 4

public Gesture getGesture ()

Added in API level 4

public int getGestureColor ()

Added in API level 4

public Path getGesturePath ( Path path)

Added in API level 4

public Path getGesturePath ()

Added in API level 4

public float getGestureStrokeAngleThreshold ()

Added in API level 4

public float getGestureStrokeLengthThreshold ()

Added in API level 4

public float getGestureStrokeSquarenessTreshold ()

Added in API level 4

public int getGestureStrokeType ()

Added in API level 4

public float getGestureStrokeWidth ()

Added in API level 4

public int getOrientation ()

Added in API level 4

public int getUncertainGestureColor ()

Added in API level 4

public boolean isEventsInterceptionEnabled ()

Added in API level 4

public boolean isFadeEnabled ()

Added in API level 4

public boolean isGestureVisible ()

Added in API level 4

public boolean isGesturing ()

Added in API level 4

public void removeAllOnGestureListeners ()

Added in API level 4

public void removeAllOnGesturePerformedListeners ()

Added in API level 4

public void removeAllOnGesturingListeners ()

Added in API level 4

public void removeOnGestureListener ( GestureOverlayView.OnGestureListener listener)

Added in API level 4

public void removeOnGesturePerformedListener ( GestureOverlayView.OnGesturePerformedListener listener)

Added in API level 4

public void removeOnGesturingListener ( GestureOverlayView.OnGesturingListener listener)

Added in API level 4

public void setEventsInterceptionEnabled (boolean enabled)

Added in API level 4

public void setFadeEnabled (boolean fadeEnabled)

Added in API level 4

public void setFadeOffset (long fadeOffset)

Added in API level 4

public void setGesture ( Gesture gesture)

Added in API level 4

public void setGestureColor (int color)

Added in API level 4

public void setGestureStrokeAngleThreshold (float gestureStrokeAngleThreshold)

Added in API level 4

public void setGestureStrokeLengthThreshold (float gestureStrokeLengthThreshold)

Added in API level 4

public void setGestureStrokeSquarenessTreshold (float gestureStrokeSquarenessTreshold)

Added in API level 4

public void setGestureStrokeType (int gestureStrokeType)

Added in API level 4

public void setGestureStrokeWidth (float gestureStrokeWidth)

Added in API level 4

public void setGestureVisible (boolean visible)

Added in API level 4

public void setOrientation (int orientation)

Added in API level 4

public void setUncertainGestureColor (int color)

Added in API level 4

Protected Methods

protected void onDetachedFromWindow ()

Added in 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.