Most visited

Recently visited

Added in API level 4

GestureOverlayView

public class GestureOverlayView
extends FrameLayout

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


用于手势输入的透明覆盖图,可放置在其他小部件的顶部或包含其他小部件。

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)

将触摸屏动作事件向下传递给目标视图,或者将此视图作为目标。

void draw(Canvas canvas)

手动将此视图(及其所有子项)呈现给定的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()

这是在视图从窗口分离时调用的。

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

定义识别手势时,叠加层是否应拦截运动事件。

必须是布尔值,可以是“ true ”或“ false ”。

这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name

这对应于全局属性资源符号 eventsInterceptionEnabled

android:fadeDuration

用户完成绘制手势后,淡出效果的持续时间(以毫秒为单位)。

必须是整数值,例如“ 100 ”。

这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name

这对应于全局属性资源符号 fadeDuration

android:fadeEnabled

定义手势在识别后是否会自动淡出。

必须是布尔值,“ true ”或“ false ”。

这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name

这对应于全局属性资源符号 fadeEnabled

android:fadeOffset

用户完成绘制后手势淡出的时间(以毫秒为单位)。

必须是整数值,例如“ 100 ”。

这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name

这对应于全局属性资源符号 fadeOffset

android:gestureColor

用于绘制手势的颜色。

必须是“ #rgb ”,“ #argb ”,“ #rrggbb ”或“ #aarrggbb ”形式的颜色值。

这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name

这对应于全局属性资源符号 gestureColor

android:gestureStrokeAngleThreshold

笔划在识别为手势之前必须包含的最小弯曲角度。

必须是浮点值,例如“ 1.2 ”。

这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name

这对应于全局属性资源符号 gestureStrokeAngleThreshold

android:gestureStrokeLengthThreshold

将笔画识别为手势之前的最小笔画长度。

必须是浮点值,例如“ 1.2 ”。

这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name

这对应于全局属性资源符号 gestureStrokeLengthThreshold

android:gestureStrokeSquarenessThreshold

在笔划识别为手势之前的笔画的方形度阈值。

必须是浮点值,例如“ 1.2 ”。

这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name

这对应于全局属性资源符号 gestureStrokeSquarenessThreshold

android:gestureStrokeType

定义定义手势的笔划类型。

必须是下列常数值之一。

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

这对应于全局属性资源符号 gestureStrokeType

android:gestureStrokeWidth

用于绘制手势的描边宽度。

必须是浮点值,例如“ 1.2 ”。

这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name

这对应于全局属性资源符号 gestureStrokeWidth

android:orientation

指示水平(方向是垂直时)还是垂直(方向是水平时)笔划是否自动定义手势。

必须是下列常数值之一。

Constant Value 描述
horizontal 0 Defines an horizontal widget.
vertical 1 Defines a vertical widget.

这对应于全局属性资源符号 orientation

android:uncertainGestureColor

颜色用于绘制用户的笔画,直到我们确定它是一个手势。

必须是“ #rgb ”,“ #argb ”,“ #rrggbb ”或“ #aarrggbb ”形式的颜色值。

这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name

这对应于全局属性资源符号 uncertainGestureColor

Constants

GESTURE_STROKE_TYPE_MULTIPLE

Added in API level 4
int GESTURE_STROKE_TYPE_MULTIPLE

常数值:1(0x00000001)

GESTURE_STROKE_TYPE_SINGLE

Added in API level 4
int GESTURE_STROKE_TYPE_SINGLE

常量值:0(0x00000000)

ORIENTATION_HORIZONTAL

Added in API level 4
int ORIENTATION_HORIZONTAL

常量值:0(0x00000000)

ORIENTATION_VERTICAL

Added in API level 4
int ORIENTATION_VERTICAL

常数值: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)

将触摸屏动作事件向下传递给目标视图,或者将此视图作为目标。

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)

手动将此视图(及其所有子项)呈现给定的Canvas。 在调用这个函数之前,视图必须已经完成了一个完整的布局。 在实现视图时,实现onDraw(android.graphics.Canvas)而不是重写此方法。 如果您确实需要重写此方法,请调用超类版本。

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 ()

这是在视图从窗口分离时调用的。 此时它不再有绘图表面。

Hooray!