# Gesture

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Inherited Constants](https://developer.android.com/reference/android/gesture/Gesture#inhconstants)\|[Fields](https://developer.android.com/reference/android/gesture/Gesture#lfields)\|[Ctors](https://developer.android.com/reference/android/gesture/Gesture#pubctors)\|[Methods](https://developer.android.com/reference/android/gesture/Gesture#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/gesture/Gesture#inhmethods)  

# Gesture

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/gesture/Gesture "View this page in Kotlin")\|Java

`
public


class
Gesture
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


implements

`[Parcelable](https://developer.android.com/reference/android/os/Parcelable)`


`

|---|-------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.gesture.Gesture |

<br />

*** ** * ** ***

A gesture is a hand-drawn shape on a touch screen. It can have one or multiple strokes. Each stroke is a sequence of timed points. A user-defined gesture can be recognized by a GestureLibrary.

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ### Inherited constants                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From interface[android.os.Parcelable](https://developer.android.com/reference/android/os/Parcelable) |-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `int` | [CONTENTS_FILE_DESCRIPTOR](https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR) Descriptor bit used with[describeContents()](https://developer.android.com/reference/android/os/Parcelable#describeContents()): indicates that the Parcelable object's flattened representation includes a file descriptor.                                                                                                                                            | | `int` | [PARCELABLE_WRITE_RETURN_VALUE](https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE) Flag for use with[writeToParcel(Parcel, int)](https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)): the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`". | |

|                                                                                                                                     ### Fields                                                                                                                                     ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------|
| ` public static final `[Creator](https://developer.android.com/reference/android/os/Parcelable.Creator)`<`[Gesture](https://developer.android.com/reference/android/gesture/Gesture)`>` | [CREATOR](https://developer.android.com/reference/android/gesture/Gesture#CREATOR) <br /> |

|                                     ### Public constructors                                     ||
|----------------------------------------------------------------------------------------------|---|
| ` `[Gesture](https://developer.android.com/reference/android/gesture/Gesture#Gesture())`() ` |

|                                                                                                                                                                                                                ### Public methods                                                                                                                                                                                                                ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`                                                                                                                                                                 | ` `[addStroke](https://developer.android.com/reference/android/gesture/Gesture#addStroke(android.gesture.GestureStroke))`(`[GestureStroke](https://developer.android.com/reference/android/gesture/GestureStroke)` stroke) ` Adds a stroke to the gesture.              |
| ` `[Object](https://developer.android.com/reference/java/lang/Object)                                                                                                   | ` `[clone](https://developer.android.com/reference/android/gesture/Gesture#clone())`() ` Creates and returns a copy of this object.                                                                                                                                     |
| ` int`                                                                                                                                                                  | ` `[describeContents](https://developer.android.com/reference/android/gesture/Gesture#describeContents())`() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.                                                  |
| ` `[RectF](https://developer.android.com/reference/android/graphics/RectF)                                                                                              | ` `[getBoundingBox](https://developer.android.com/reference/android/gesture/Gesture#getBoundingBox())`() `                                                                                                                                                              |
| ` long`                                                                                                                                                                 | ` `[getID](https://developer.android.com/reference/android/gesture/Gesture#getID())`() `                                                                                                                                                                                |
| ` float`                                                                                                                                                                | ` `[getLength](https://developer.android.com/reference/android/gesture/Gesture#getLength())`() ` Calculates the total length of the gesture.                                                                                                                            |
| ` `[ArrayList](https://developer.android.com/reference/java/util/ArrayList)`<`[GestureStroke](https://developer.android.com/reference/android/gesture/GestureStroke)`>` | ` `[getStrokes](https://developer.android.com/reference/android/gesture/Gesture#getStrokes())`() `                                                                                                                                                                      |
| ` int`                                                                                                                                                                  | ` `[getStrokesCount](https://developer.android.com/reference/android/gesture/Gesture#getStrokesCount())`() `                                                                                                                                                            |
| ` `[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap)                                                                                            | ` `[toBitmap](https://developer.android.com/reference/android/gesture/Gesture#toBitmap(int,%20int,%20int,%20int,%20int))`(int width, int height, int edge, int numSample, int color) ` Creates a bitmap of the gesture with a transparent background.                   |
| ` `[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap)                                                                                            | ` `[toBitmap](https://developer.android.com/reference/android/gesture/Gesture#toBitmap(int,%20int,%20int,%20int))`(int width, int height, int inset, int color) ` Creates a bitmap of the gesture with a transparent background.                                        |
| ` `[Path](https://developer.android.com/reference/android/graphics/Path)                                                                                                | ` `[toPath](https://developer.android.com/reference/android/gesture/Gesture#toPath(android.graphics.Path))`(`[Path](https://developer.android.com/reference/android/graphics/Path)` path) `                                                                             |
| ` `[Path](https://developer.android.com/reference/android/graphics/Path)                                                                                                | ` `[toPath](https://developer.android.com/reference/android/gesture/Gesture#toPath(int,%20int,%20int,%20int))`(int width, int height, int edge, int numSample) `                                                                                                        |
| ` `[Path](https://developer.android.com/reference/android/graphics/Path)                                                                                                | ` `[toPath](https://developer.android.com/reference/android/gesture/Gesture#toPath(android.graphics.Path,%20int,%20int,%20int,%20int))`(`[Path](https://developer.android.com/reference/android/graphics/Path)` path, int width, int height, int edge, int numSample) ` |
| ` `[Path](https://developer.android.com/reference/android/graphics/Path)                                                                                                | ` `[toPath](https://developer.android.com/reference/android/gesture/Gesture#toPath())`() `                                                                                                                                                                              |
| ` void`                                                                                                                                                                 | ` `[writeToParcel](https://developer.android.com/reference/android/gesture/Gesture#writeToParcel(android.os.Parcel,%20int))`(`[Parcel](https://developer.android.com/reference/android/os/Parcel)` out, int flags) ` Flatten this object in to a Parcel.                |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||
| From interface` `[android.os.Parcelable](https://developer.android.com/reference/android/os/Parcelable)` ` |------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract int`  | ` `[describeContents](https://developer.android.com/reference/android/os/Parcelable#describeContents())`() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.                                    | | ` abstract void` | ` `[writeToParcel](https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int))`(`[Parcel](https://developer.android.com/reference/android/os/Parcel)` dest, int flags) ` Flatten this object in to a Parcel. | ||

## Fields

### CREATOR

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final Creator<Gesture> CREATOR
```

<br />

<br />

## Public constructors

### Gesture

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Gesture ()
```

<br />

<br />

## Public methods

### addStroke

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void addStroke (GestureStroke stroke)
```

Adds a stroke to the gesture.

<br />

### clone

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Object clone ()
```

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object`x`, the expression:
>
> ```
>  x.clone() != x
> ```
will be true, and that the expression:
>
> ```
>  x.clone().getClass() == x.getClass()
> ```
will be`true`, but these are not absolute requirements. While it is typically the case that:
>
> ```
>  x.clone().equals(x)
> ```
will be`true`, this is not an absolute requirement.

By convention, the returned object should be obtained by calling`super.clone`. If a class and all of its superclasses (except`Object`) obey this convention, it will be the case that`x.clone().getClass() == x.getClass()`.

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by`super.clone`before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by`super.clone`need to be modified.

<br />

|                                               Returns                                                ||
|--------------------------------------------------------------------|----------------------------------|
| [Object](https://developer.android.com/reference/java/lang/Object) | a clone of this instance. <br /> |

### describeContents

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int describeContents ()
```

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of[writeToParcel(android.os.Parcel, int)](https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)), the return value of this method must include the[CONTENTS_FILE_DESCRIPTOR](https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR)bit.

<br />

|                                                                                                                         Returns                                                                                                                         ||
|-------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either`0`or[CONTENTS_FILE_DESCRIPTOR](https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR) <br /> |

### getBoundingBox

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public RectF getBoundingBox ()
```

<br />

<br />

|                                                     Returns                                                     ||
|-------------------------------------------------------------------------|----------------------------------------|
| [RectF](https://developer.android.com/reference/android/graphics/RectF) | the bounding box of the gesture <br /> |

### getID

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public long getID ()
```

<br />

<br />

|               Returns                ||
|--------|------------------------------|
| `long` | the id of the gesture <br /> |

### getLength

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public float getLength ()
```

Calculates the total length of the gesture. When there are multiple strokes in the gesture, this returns the sum of the lengths of all the strokes.

<br />

|                  Returns                  ||
|---------|----------------------------------|
| `float` | the length of the gesture <br /> |

### getStrokes

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public ArrayList<GestureStroke> getStrokes ()
```

<br />

<br />

|                                                                                                   Returns                                                                                                   ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------|
| [ArrayList](https://developer.android.com/reference/java/util/ArrayList)`<`[GestureStroke](https://developer.android.com/reference/android/gesture/GestureStroke)`>` | all the strokes of the gesture <br /> |

### getStrokesCount

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int getStrokesCount ()
```

<br />

<br />

|                           Returns                            ||
|-------|-------------------------------------------------------|
| `int` | the number of strokes included by this gesture <br /> |

### toBitmap

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Bitmap toBitmap (int width, 
                int height, 
                int edge, 
                int numSample, 
                int color)
```

Creates a bitmap of the gesture with a transparent background.

<br />

|                     Parameters                      ||
|----------|-------------------------------------------|
| `width`  | `int`: width of the target bitmap <br />  |
| `height` | `int`: height of the target bitmap <br /> |
| `edge`   | `int`: the edge <br />                    |

|                                           Returns                                            ||
|---------------------------------------------------------------------------|-------------------|
| [Bitmap](https://developer.android.com/reference/android/graphics/Bitmap) | the bitmap <br /> |

### toBitmap

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Bitmap toBitmap (int width, 
                int height, 
                int inset, 
                int color)
```

Creates a bitmap of the gesture with a transparent background.

<br />

|                                           Returns                                            ||
|---------------------------------------------------------------------------|-------------------|
| [Bitmap](https://developer.android.com/reference/android/graphics/Bitmap) | the bitmap <br /> |

### toPath

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Path toPath (Path path)
```

<br />

<br />

|      Parameters       ||
|--------|---------------|
| `path` | `Path` <br /> |

|                                    Returns                                    ||
|-----------------------------------------------------------------------|--------|
| [Path](https://developer.android.com/reference/android/graphics/Path) | <br /> |

### toPath

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Path toPath (int width, 
                int height, 
                int edge, 
                int numSample)
```

<br />

<br />

|        Parameters         ||
|-------------|--------------|
| `width`     | `int` <br /> |
| `height`    | `int` <br /> |
| `edge`      | `int` <br /> |
| `numSample` | `int` <br /> |

|                                    Returns                                    ||
|-----------------------------------------------------------------------|--------|
| [Path](https://developer.android.com/reference/android/graphics/Path) | <br /> |

### toPath

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Path toPath (Path path, 
                int width, 
                int height, 
                int edge, 
                int numSample)
```

<br />

<br />

|         Parameters         ||
|-------------|---------------|
| `path`      | `Path` <br /> |
| `width`     | `int` <br />  |
| `height`    | `int` <br />  |
| `edge`      | `int` <br />  |
| `numSample` | `int` <br />  |

|                                    Returns                                    ||
|-----------------------------------------------------------------------|--------|
| [Path](https://developer.android.com/reference/android/graphics/Path) | <br /> |

### toPath

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Path toPath ()
```

<br />

<br />

|                                    Returns                                    ||
|-----------------------------------------------------------------------|--------|
| [Path](https://developer.android.com/reference/android/graphics/Path) | <br /> |

### writeToParcel

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void writeToParcel (Parcel out, 
                int flags)
```

Flatten this object in to a Parcel.

<br />

|                                                                                                                                                                                                                               Parameters                                                                                                                                                                                                                                ||
|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `out`   | `Parcel`: The Parcel in which the object should be written. This value cannot be`null`. <br />                                                                                                                                                                                                                                                                                                                                                                 |
| `flags` | `int`: Additional flags about how the object should be written. May be 0 or[Parcelable.PARCELABLE_WRITE_RETURN_VALUE](https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE). Value is either`0`or a combination of[Parcelable.PARCELABLE_WRITE_RETURN_VALUE](https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE), and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES <br /> |