{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}
public class MotionEventBuilder
A helper builder for creating MotionEvent's.
Default values for unspecified attributes are 0 unless otherwise noted.
Public methods |
|
|---|---|
@NonNull MotionEvent |
build()Returns a MotionEvent with the provided data or reasonable defaults. |
static @NonNull MotionEventBuilder |
Start building a new MotionEvent. |
@NonNull MotionEventBuilder |
Sets the action. |
@NonNull MotionEventBuilder |
setActionIndex(@NonNull int pointerIndex)Sets the pointer index associated with the action. |
@NonNull MotionEventBuilder |
setButtonState(@NonNull int buttonState)Sets the button state. |
@NonNull MotionEventBuilder |
setDeviceId(@NonNull int deviceId)Sets the device id. |
@NonNull MotionEventBuilder |
setDownTime(@NonNull long downTime)Sets the down time. |
@NonNull MotionEventBuilder |
setEdgeFlags(@NonNull int edgeFlags)Sets the edge flags. |
@NonNull MotionEventBuilder |
setEventTime(@NonNull long eventTime)Sets the event time. |
@NonNull MotionEventBuilder |
Sets the flags. |
@NonNull MotionEventBuilder |
setMetaState(@NonNull int metastate)Sets the metaState. |
@NonNull MotionEventBuilder |
setPointer(@NonNull float x, @NonNull float y)Simple mechanism to add a pointer to the MotionEvent. |
@NonNull MotionEventBuilder |
setPointer(An expanded variant of |
@NonNull MotionEventBuilder |
Sets the source. |
@NonNull MotionEventBuilder |
setXPrecision(@NonNull float xPrecision)Sets the x precision. |
@NonNull MotionEventBuilder |
setYPrecision(@NonNull float yPrecision)Sets the y precision. |
@NonNull
public MotionEvent build()
Returns a MotionEvent with the provided data or reasonable defaults.
@NonNull
public static MotionEventBuilder newBuilder()
Start building a new MotionEvent.
| Returns | |
|---|---|
MotionEventBuilder |
a new MotionEventBuilder. |
@NonNull
public MotionEventBuilder setAction(@NonNull int action)
Sets the action. Default is MotionEvent.ACTION_DOWN.
| See also | |
|---|---|
MotionEvent |
android.view.MotionEvent#getAction() |
@NonNull
public MotionEventBuilder setActionIndex(@NonNull int pointerIndex)
Sets the pointer index associated with the action.
| See also | |
|---|---|
MotionEvent |
android.view.MotionEvent#getActionIndex() |
@NonNull
public MotionEventBuilder setButtonState(@NonNull int buttonState)
Sets the button state.
| See also | |
|---|---|
MotionEvent |
android.view.MotionEvent#getButtonState() |
@NonNull
public MotionEventBuilder setDeviceId(@NonNull int deviceId)
Sets the device id.
| See also | |
|---|---|
MotionEvent |
android.view.MotionEvent#getDeviceId() |
@NonNull
public MotionEventBuilder setDownTime(@NonNull long downTime)
Sets the down time.
| See also | |
|---|---|
MotionEvent |
android.view.MotionEvent#getDownTime() |
@NonNull
public MotionEventBuilder setEdgeFlags(@NonNull int edgeFlags)
Sets the edge flags.
| See also | |
|---|---|
MotionEvent |
android.view.MotionEvent#getEdgeFlags() |
@NonNull
public MotionEventBuilder setEventTime(@NonNull long eventTime)
Sets the event time. Default is SystemClock.uptimeMillis().
| See also | |
|---|---|
MotionEvent |
android.view.MotionEvent#getEventTime() |
@NonNull
public MotionEventBuilder setFlags(@NonNull int flags)
Sets the flags.
| See also | |
|---|---|
MotionEvent |
android.view.MotionEvent#getFlags() |
@NonNull
public MotionEventBuilder setMetaState(@NonNull int metastate)
Sets the metaState.
| See also | |
|---|---|
MotionEvent |
android.view.MotionEvent#getMetaState() |
@NonNull
public MotionEventBuilder setPointer(@NonNull float x, @NonNull float y)
Simple mechanism to add a pointer to the MotionEvent.
Can be called multiple times to add multiple pointers to the event.
@NonNull
public MotionEventBuilder setPointer(
@NonNull PointerProperties pointerProperties,
@NonNull PointerCoords pointerCoords
)
An expanded variant of setPointer that supports specifying all pointer properties and coords data.
@NonNull
public MotionEventBuilder setSource(@NonNull int source)
Sets the source.
| See also | |
|---|---|
MotionEvent |
android.view.MotionEvent#getSource() |
@NonNull
public MotionEventBuilder setXPrecision(@NonNull float xPrecision)
Sets the x precision.
| See also | |
|---|---|
MotionEvent |
android.view.MotionEvent#getXPrecision() |
@NonNull
public MotionEventBuilder setYPrecision(@NonNull float yPrecision)
Sets the y precision.
| See also | |
|---|---|
MotionEvent |
android.view.MotionEvent#getYPrecision() |