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

Constants

int GESTURE_STROKE_TYPE_MULTIPLE

int GESTURE_STROKE_TYPE_SINGLE

int ORIENTATION_HORIZONTAL

int ORIENTATION_VERTICAL

Inherited constants

Inherited fields

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

XML attributes

android:eventsInterceptionEnabled

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

May be a boolean value, such as "true" or "false".

android:fadeDuration

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

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

android:fadeEnabled

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

May be a boolean value, such as "true" or "false".

android:fadeOffset

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

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

android:gestureColor

Color used to draw a gesture.

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

android:gestureStrokeAngleThreshold

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

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

android:gestureStrokeLengthThreshold

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

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

android:gestureStrokeSquarenessThreshold

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

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

android:gestureStrokeType

Defines the type of strokes that define a gesture.

Must be one of the following constant values.

ConstantValueDescription
multiple1A gesture is made of multiple strokes.
single0A gesture is made of only one stroke.

android:gestureStrokeWidth

Width of the stroke used to draw the gesture.

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

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
horizontal0Defines an horizontal widget.
vertical1Defines a vertical widget.

android:uncertainGestureColor

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

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

Constants

GESTURE_STROKE_TYPE_MULTIPLE

Added in API level 4
public static final int GESTURE_STROKE_TYPE_MULTIPLE

Constant Value: 1 (0x00000001)

GESTURE_STROKE_TYPE_SINGLE

Added in API level 4
public static final int GESTURE_STROKE_TYPE_SINGLE

Constant Value: 0 (0x00000000)

ORIENTATION_HORIZONTAL

Added in API level 4
public static final int ORIENTATION_HORIZONTAL

Constant Value: 0 (0x00000000)

ORIENTATION_VERTICAL

Added in API level 4
public static final int ORIENTATION_VERTICAL

Constant Value: 1 (0x00000001)

Public constructors

GestureOverlayView

Added in API level 4
public GestureOverlayView (Context context)

Parameters
context Context

GestureOverlayView

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

Parameters
context Context

attrs AttributeSet

GestureOverlayView

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

Parameters
context Context

attrs AttributeSet

defStyleAttr int

GestureOverlayView

Added in API level 4
public 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
public void addOnGestureListener (GestureOverlayView.OnGestureListener listener)

Parameters
listener GestureOverlayView.OnGestureListener

addOnGesturePerformedListener

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

Parameters
listener GestureOverlayView.OnGesturePerformedListener

addOnGesturingListener

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

Parameters
listener GestureOverlayView.OnGesturingListener

cancelClearAnimation

Added in API level 4
public void cancelClearAnimation ()

cancelGesture

Added in API level 4
public void cancelGesture ()

clear

Added in API level 4
public void clear (boolean animated)

Parameters
animated boolean

dispatchTouchEvent

Added in API level 4
public 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
public 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.
If you override this method you must call through to the superclass implementation.

Parameters
canvas Canvas: The Canvas to which the View is rendered. This value cannot be null.

getCurrentStroke

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

Returns
ArrayList<GesturePoint>

getFadeOffset

Added in API level 4
public long getFadeOffset ()

Returns
long

getGesture

Added in API level 4
public Gesture getGesture ()

Returns
Gesture

getGestureColor

Added in API level 4
public int getGestureColor ()

Returns
int

getGesturePath

Added in API level 4
public Path getGesturePath (Path path)

Parameters
path Path

Returns
Path

getGesturePath

Added in API level 4
public Path getGesturePath ()

Returns
Path

getGestureStrokeAngleThreshold

Added in API level 4
public float getGestureStrokeAngleThreshold ()

Returns
float

getGestureStrokeLengthThreshold

Added in API level 4
public float getGestureStrokeLengthThreshold ()

Returns
float

getGestureStrokeSquarenessTreshold

Added in API level 4
public float getGestureStrokeSquarenessTreshold ()

Returns
float

getGestureStrokeType

Added in API level 4
public int getGestureStrokeType ()

Returns
int

getGestureStrokeWidth

Added in API level 4
public float getGestureStrokeWidth ()

Returns
float

getOrientation

Added in API level 4
public int getOrientation ()

Returns
int

getUncertainGestureColor

Added in API level 4
public int getUncertainGestureColor ()

Returns
int

isEventsInterceptionEnabled

Added in API level 4
public boolean isEventsInterceptionEnabled ()

Returns
boolean

isFadeEnabled

Added in API level 4
public boolean isFadeEnabled ()

Returns
boolean

isGestureVisible

Added in API level 4
public boolean isGestureVisible ()

Returns
boolean

isGesturing

Added in API level 4
public boolean isGesturing ()

Returns
boolean

removeAllOnGestureListeners

Added in API level 4
public void removeAllOnGestureListeners ()

removeAllOnGesturePerformedListeners

Added in API level 4
public void removeAllOnGesturePerformedListeners ()

removeAllOnGesturingListeners

Added in API level 4
public void removeAllOnGesturingListeners ()

removeOnGestureListener

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

Parameters
listener GestureOverlayView.OnGestureListener

removeOnGesturePerformedListener

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

Parameters
listener GestureOverlayView.OnGesturePerformedListener

removeOnGesturingListener

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

Parameters
listener GestureOverlayView.OnGesturingListener

setEventsInterceptionEnabled

Added in API level 4
public void setEventsInterceptionEnabled (boolean enabled)

Parameters
enabled boolean

setFadeEnabled

Added in API level 4
public void setFadeEnabled (boolean fadeEnabled)

Parameters
fadeEnabled boolean

setFadeOffset

Added in API level 4
public void setFadeOffset (long fadeOffset)

Parameters
fadeOffset long

setGesture

Added in API level 4
public void setGesture (Gesture gesture)

Parameters
gesture Gesture

setGestureColor

Added in API level 4
public void setGestureColor (int color)

Parameters
color int

setGestureStrokeAngleThreshold

Added in API level 4
public void setGestureStrokeAngleThreshold (float gestureStrokeAngleThreshold)

Parameters
gestureStrokeAngleThreshold float

setGestureStrokeLengthThreshold

Added in API level 4
public void setGestureStrokeLengthThreshold (float gestureStrokeLengthThreshold)

Parameters
gestureStrokeLengthThreshold float

setGestureStrokeSquarenessTreshold

Added in API level 4
public void setGestureStrokeSquarenessTreshold (float gestureStrokeSquarenessTreshold)

Parameters
gestureStrokeSquarenessTreshold float

setGestureStrokeType

Added in API level 4
public void setGestureStrokeType (int gestureStrokeType)

Parameters
gestureStrokeType int

setGestureStrokeWidth

Added in API level 4
public void setGestureStrokeWidth (float gestureStrokeWidth)

Parameters
gestureStrokeWidth float

setGestureVisible

Added in API level 4
public void setGestureVisible (boolean visible)

Parameters
visible boolean

setOrientation

Added in API level 4
public void setOrientation (int orientation)

Parameters
orientation int

setUncertainGestureColor

Added in API level 4
public void setUncertainGestureColor (int color)

Parameters
color int

Protected methods

onDetachedFromWindow

Added in API level 4
protected void onDetachedFromWindow ()

This is called when the view is detached from a window. At this point it no longer has a surface for drawing.
If you override this method you must call through to the superclass implementation.