{% setvar book_path %}/reference/kotlin/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

MotionEventBuilder

class MotionEventBuilder


A helper builder for creating MotionEvent's.

Default values for unspecified attributes are 0 unless otherwise noted.

Summary

Public constructors

Public functions

MotionEvent!

Returns a MotionEvent with the provided data or reasonable defaults.

java-static MotionEventBuilder!

Start building a new MotionEvent.

MotionEventBuilder!
setAction(action: Int)

Sets the action.

MotionEventBuilder!
setActionIndex(pointerIndex: Int)

Sets the pointer index associated with the action.

MotionEventBuilder!
setButtonState(buttonState: Int)

Sets the button state.

MotionEventBuilder!
setDeviceId(deviceId: Int)

Sets the device id.

MotionEventBuilder!
setDownTime(downTime: Long)

Sets the down time.

MotionEventBuilder!
setEdgeFlags(edgeFlags: Int)

Sets the edge flags.

MotionEventBuilder!
setEventTime(eventTime: Long)

Sets the event time.

MotionEventBuilder!
setFlags(flags: Int)

Sets the flags.

MotionEventBuilder!
setMetaState(metastate: Int)

Sets the metaState.

MotionEventBuilder!

Simple mechanism to add a pointer to the MotionEvent.

MotionEventBuilder!
setPointer(
    pointerProperties: PointerProperties!,
    pointerCoords: PointerCoords!
)

An expanded variant of setPointer that supports specifying all pointer properties and coords data.

MotionEventBuilder!
setSource(source: Int)

Sets the source.

MotionEventBuilder!
setXPrecision(xPrecision: Float)

Sets the x precision.

MotionEventBuilder!
setYPrecision(yPrecision: Float)

Sets the y precision.

Public constructors

MotionEventBuilder

MotionEventBuilder()

Public functions

build

fun build(): MotionEvent!

Returns a MotionEvent with the provided data or reasonable defaults.

newBuilder

java-static fun newBuilder(): MotionEventBuilder!

Start building a new MotionEvent.

Returns
MotionEventBuilder!

a new MotionEventBuilder.

setAction

fun setAction(action: Int): MotionEventBuilder!

Sets the action. Default is MotionEvent.ACTION_DOWN.

See also
MotionEvent

setActionIndex

fun setActionIndex(pointerIndex: Int): MotionEventBuilder!

Sets the pointer index associated with the action.

See also
MotionEvent

setButtonState

fun setButtonState(buttonState: Int): MotionEventBuilder!

Sets the button state.

See also
MotionEvent

setDeviceId

fun setDeviceId(deviceId: Int): MotionEventBuilder!

Sets the device id.

See also
MotionEvent

setDownTime

fun setDownTime(downTime: Long): MotionEventBuilder!

Sets the down time.

See also
MotionEvent

setEdgeFlags

fun setEdgeFlags(edgeFlags: Int): MotionEventBuilder!

Sets the edge flags.

See also
MotionEvent

setEventTime

fun setEventTime(eventTime: Long): MotionEventBuilder!

Sets the event time. Default is SystemClock.uptimeMillis().

See also
MotionEvent

setFlags

fun setFlags(flags: Int): MotionEventBuilder!

Sets the flags.

See also
MotionEvent

setMetaState

fun setMetaState(metastate: Int): MotionEventBuilder!

Sets the metaState.

See also
MotionEvent

setPointer

fun setPointer(x: Float, y: Float): MotionEventBuilder!

Simple mechanism to add a pointer to the MotionEvent.

Can be called multiple times to add multiple pointers to the event.

setPointer

fun setPointer(
    pointerProperties: PointerProperties!,
    pointerCoords: PointerCoords!
): MotionEventBuilder!

An expanded variant of setPointer that supports specifying all pointer properties and coords data.

setSource

fun setSource(source: Int): MotionEventBuilder!

Sets the source.

See also
MotionEvent

setXPrecision

fun setXPrecision(xPrecision: Float): MotionEventBuilder!

Sets the x precision.

See also
MotionEvent

setYPrecision

fun setYPrecision(yPrecision: Float): MotionEventBuilder!

Sets the y precision.

See also
MotionEvent