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
abstract void bringChildToFront(View child)
Change the z order of the child so it's on top of all other children.
abstract boolean canResolveLayoutDirection()
Tells if this view parent can resolve the layout direction.
abstract boolean canResolveTextAlignment()
Tells if this view parent can resolve the text alignment.
abstract boolean canResolveTextDirection()
Tells if this view parent can resolve the text direction.
abstract void childDrawableStateChanged(View child)
This method is called on the parent when a child's drawable state has changed.
abstract void childHasTransientStateChanged(View child, boolean hasTransientState)
Called when a child view now has or no longer is tracking transient state.
abstract void clearChildFocus(View child)
Called when a child of this parent is giving up focus
abstract void createContextMenu(ContextMenu menu)
Have the parent populate the specified context menu if it has anything to add (and then recurse on its parent).
abstract View focusSearch(View v, int direction)
Find the nearest view in the specified direction that wants to take focus
abstract void focusableViewAvailable(View v)
Tells the parent that a new focusable view has become available.
abstract boolean getChildVisibleRect(View child, Rect r, Point offset)
Compute the visible part of a rectangular region defined in terms of a child view's coordinates.
abstract int getLayoutDirection()
Return this view parent layout direction.
abstract ViewParent getParent()
Returns the parent if it exists, or null.
abstract ViewParent getParentForAccessibility()
Gets the parent of a given View for accessibility.
abstract int getTextAlignment()
Return this view parent text alignment.
abstract int getTextDirection()
Return this view parent text direction.
abstract void invalidateChild(View child, Rect r)
All or part of a child is dirty and needs to be redrawn.
abstract ViewParent invalidateChildInParent(int[] location, Rect r)
All or part of a child is dirty and needs to be redrawn.
abstract boolean isLayoutDirectionResolved()
Tells if this view parent layout direction is resolved.
abstract boolean isLayoutRequested()
Indicates whether layout was requested on this view parent.
abstract boolean isTextAlignmentResolved()
Tells if this view parent text alignment is resolved.
abstract boolean isTextDirectionResolved()
Tells if this view parent text direction is resolved.
abstract void notifySubtreeAccessibilityStateChanged(View child, View source, int changeType)
Notifies a view parent that the accessibility state of one of its descendants has changed and that the structure of the subtree is different.
abstract void recomputeViewAttributes(View child)
Tell view hierarchy that the global view attributes need to be re-evaluated.
abstract void requestChildFocus(View child, View focused)
Called when a child of this parent wants focus
abstract boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate)
Called when a child of this group wants a particular rectangle to be positioned onto the screen.
abstract void requestDisallowInterceptTouchEvent(boolean disallowIntercept)
Called when a child does not want this parent and its ancestors to intercept touch events with onInterceptTouchEvent(MotionEvent).
abstract void requestFitSystemWindows()
Ask that a new dispatch of View.fitSystemWindows(Rect) be performed.
abstract void requestLayout()
Called when something has changed which has invalidated the layout of a child of this view parent.
abstract boolean requestSendAccessibilityEvent(View child, AccessibilityEvent event)
Called by a child to request from its parent to send an AccessibilityEvent.
abstract void requestTransparentRegion(View child)
Called when a child wants the view hierarchy to gather and report transparent regions to the window compositor.
abstract boolean showContextMenuForChild(View originalView)
Bring up a context menu for the specified view or its ancestors.
abstract ActionMode startActionModeForChild(View originalView, ActionMode.Callback callback)
Start an action mode for the specified view.
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.

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

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.

ConstantValueDescription
horizontal0 Defines an horizontal widget.
vertical1 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.