Skip to content

Most visited

Recently visited

navigation

GestureOverlayView

public class GestureOverlayView
extends FrameLayout

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


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

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. 

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

Inherited constants

From class android.view.ViewGroup
From class android.view.View

Inherited fields

From class android.view.View

Public constructors

GestureOverlayView(Context context)
GestureOverlayView(Context context, AttributeSet attrs)
GestureOverlayView(Context context, AttributeSet attrs, int defStyleAttr)
GestureOverlayView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

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.

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.view.ViewParent
From interface android.view.ViewManager
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
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.

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.

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.

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.

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.

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.

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.

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.

android:gestureStrokeType

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.

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.

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.

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

This corresponds to the global attribute resource symbol orientation.

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.

Constants

GESTURE_STROKE_TYPE_MULTIPLE

Added in API level 4
int GESTURE_STROKE_TYPE_MULTIPLE

Constant Value: 1 (0x00000001)

GESTURE_STROKE_TYPE_SINGLE

Added in API level 4
int GESTURE_STROKE_TYPE_SINGLE

Constant Value: 0 (0x00000000)

ORIENTATION_HORIZONTAL

Added in API level 4
int ORIENTATION_HORIZONTAL

Constant Value: 0 (0x00000000)

ORIENTATION_VERTICAL

Added in API level 4
int ORIENTATION_VERTICAL

Constant Value: 1 (0x00000001)

Public constructors

GestureOverlayView

Added in API level 4
GestureOverlayView (Context context)

Parameters
context Context

GestureOverlayView

Added in API level 4
GestureOverlayView (Context context, 
                AttributeSet attrs)

Parameters
context Context
attrs AttributeSet

GestureOverlayView

Added in API level 4
GestureOverlayView (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context
attrs AttributeSet
defStyleAttr int

GestureOverlayView

Added in API level 21
GestureOverlayView (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)

Parameters
context Context
attrs AttributeSet
defStyleAttr int
defStyleRes int

Public methods

addOnGestureListener

Added in API level 4
void addOnGestureListener (GestureOverlayView.OnGestureListener listener)

Parameters
listener GestureOverlayView.OnGestureListener

addOnGesturePerformedListener

Added in API level 4
void addOnGesturePerformedListener (GestureOverlayView.OnGesturePerformedListener listener)

Parameters
listener GestureOverlayView.OnGesturePerformedListener

addOnGesturingListener

Added in API level 4
void addOnGesturingListener (GestureOverlayView.OnGesturingListener listener)

Parameters
listener GestureOverlayView.OnGesturingListener

cancelClearAnimation

Added in API level 4
void cancelClearAnimation ()

cancelGesture

Added in API level 4
void cancelGesture ()

clear

Added in API level 4
void clear (boolean animated)

Parameters
animated boolean

dispatchTouchEvent

Added in API level 4
boolean dispatchTouchEvent (MotionEvent event)

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

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

draw

Added in API level 4
void draw (Canvas canvas)

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 Canvas: The Canvas to which the View is rendered.

getCurrentStroke

Added in API level 4
ArrayList<GesturePoint> getCurrentStroke ()

Returns
ArrayList<GesturePoint>

getFadeOffset

Added in API level 4
long getFadeOffset ()

Returns
long

getGesture

Added in API level 4
Gesture getGesture ()

Returns
Gesture

getGestureColor

Added in API level 4
int getGestureColor ()

Returns
int

getGesturePath

Added in API level 4
Path getGesturePath (Path path)

Parameters
path Path
Returns
Path

getGesturePath

Added in API level 4
Path getGesturePath ()

Returns
Path

getGestureStrokeAngleThreshold

Added in API level 4
float getGestureStrokeAngleThreshold ()

Returns
float

getGestureStrokeLengthThreshold

Added in API level 4
float getGestureStrokeLengthThreshold ()

Returns
float

getGestureStrokeSquarenessTreshold

Added in API level 4
float getGestureStrokeSquarenessTreshold ()

Returns
float

getGestureStrokeType

Added in API level 4
int getGestureStrokeType ()

Returns
int

getGestureStrokeWidth

Added in API level 4
float getGestureStrokeWidth ()

Returns
float

getOrientation

Added in API level 4
int getOrientation ()

Returns
int

getUncertainGestureColor

Added in API level 4
int getUncertainGestureColor ()

Returns
int

isEventsInterceptionEnabled

Added in API level 4
boolean isEventsInterceptionEnabled ()

Returns
boolean

isFadeEnabled

Added in API level 4
boolean isFadeEnabled ()

Returns
boolean

isGestureVisible

Added in API level 4
boolean isGestureVisible ()

Returns
boolean

isGesturing

Added in API level 4
boolean isGesturing ()

Returns
boolean

removeAllOnGestureListeners

Added in API level 4
void removeAllOnGestureListeners ()

removeAllOnGesturePerformedListeners

Added in API level 4
void removeAllOnGesturePerformedListeners ()

removeAllOnGesturingListeners

Added in API level 4
void removeAllOnGesturingListeners ()

removeOnGestureListener

Added in API level 4
void removeOnGestureListener (GestureOverlayView.OnGestureListener listener)

Parameters
listener GestureOverlayView.OnGestureListener

removeOnGesturePerformedListener

Added in API level 4
void removeOnGesturePerformedListener (GestureOverlayView.OnGesturePerformedListener listener)

Parameters
listener GestureOverlayView.OnGesturePerformedListener

removeOnGesturingListener

Added in API level 4
void removeOnGesturingListener (GestureOverlayView.OnGesturingListener listener)

Parameters
listener GestureOverlayView.OnGesturingListener

setEventsInterceptionEnabled

Added in API level 4
void setEventsInterceptionEnabled (boolean enabled)

Parameters
enabled boolean

setFadeEnabled

Added in API level 4
void setFadeEnabled (boolean fadeEnabled)

Parameters
fadeEnabled boolean

setFadeOffset

Added in API level 4
void setFadeOffset (long fadeOffset)

Parameters
fadeOffset long

setGesture

Added in API level 4
void setGesture (Gesture gesture)

Parameters
gesture Gesture

setGestureColor

Added in API level 4
void setGestureColor (int color)

Parameters
color int

setGestureStrokeAngleThreshold

Added in API level 4
void setGestureStrokeAngleThreshold (float gestureStrokeAngleThreshold)

Parameters
gestureStrokeAngleThreshold float

setGestureStrokeLengthThreshold

Added in API level 4
void setGestureStrokeLengthThreshold (float gestureStrokeLengthThreshold)

Parameters
gestureStrokeLengthThreshold float

setGestureStrokeSquarenessTreshold

Added in API level 4
void setGestureStrokeSquarenessTreshold (float gestureStrokeSquarenessTreshold)

Parameters
gestureStrokeSquarenessTreshold float

setGestureStrokeType

Added in API level 4
void setGestureStrokeType (int gestureStrokeType)

Parameters
gestureStrokeType int

setGestureStrokeWidth

Added in API level 4
void setGestureStrokeWidth (float gestureStrokeWidth)

Parameters
gestureStrokeWidth float

setGestureVisible

Added in API level 4
void setGestureVisible (boolean visible)

Parameters
visible boolean

setOrientation

Added in API level 4
void setOrientation (int orientation)

Parameters
orientation int

setUncertainGestureColor

Added in API level 4
void setUncertainGestureColor (int color)

Parameters
color int

Protected methods

onDetachedFromWindow

Added in API level 4
void onDetachedFromWindow ()

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

This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.