Added in API level 1

OnGestureListener


interface OnGestureListener
android.view.GestureDetector.OnGestureListener

The listener that is used to notify when gestures occur. If you want to listen for all the different gestures then implement this interface. If you only want to listen for a subset it might be easier to extend SimpleOnGestureListener.

Summary

Public methods
abstract Boolean

Notified when a tap occurs with the down MotionEvent that triggered it.

abstract Boolean
onFling(e1: MotionEvent?, e2: MotionEvent, velocityX: Float, velocityY: Float)

Notified of a fling event when it occurs with the initial on down MotionEvent and the matching up MotionEvent.

abstract Unit

Notified when a long press occurs with the initial on down MotionEvent that trigged it.

abstract Boolean
onScroll(e1: MotionEvent?, e2: MotionEvent, distanceX: Float, distanceY: Float)

Notified when a scroll occurs with the initial on down MotionEvent and the current move MotionEvent.

abstract Unit

The user has performed a down MotionEvent and not performed a move or up yet.

abstract Boolean

Notified when a tap occurs with the up MotionEvent that triggered it.

Public methods

onDown

Added in API level 1
abstract fun onDown(e: MotionEvent): Boolean

Notified when a tap occurs with the down MotionEvent that triggered it. This will be triggered immediately for every down event. All other events should be preceded by this.

Parameters
e MotionEvent: The down motion event. This value cannot be null.

onFling

Added in API level 1
abstract fun onFling(
    e1: MotionEvent?,
    e2: MotionEvent,
    velocityX: Float,
    velocityY: Float
): Boolean

Notified of a fling event when it occurs with the initial on down MotionEvent and the matching up MotionEvent. The calculated velocity is supplied along the x and y axis in pixels per second.

Parameters
e1 MotionEvent?: The first down motion event that started the fling. A null event indicates an incomplete event stream or error state.
e2 MotionEvent: The move motion event that triggered the current onFling. This value cannot be null.
velocityX Float: The velocity of this fling measured in pixels per second along the x axis.
velocityY Float: The velocity of this fling measured in pixels per second along the y axis.
Return
Boolean true if the event is consumed, else false

onLongPress

Added in API level 1
abstract fun onLongPress(e: MotionEvent): Unit

Notified when a long press occurs with the initial on down MotionEvent that trigged it.

Parameters
e MotionEvent: The initial on down motion event that started the longpress. This value cannot be null.

onScroll

Added in API level 1
abstract fun onScroll(
    e1: MotionEvent?,
    e2: MotionEvent,
    distanceX: Float,
    distanceY: Float
): Boolean

Notified when a scroll occurs with the initial on down MotionEvent and the current move MotionEvent. The distance in x and y is also supplied for convenience.

Parameters
e1 MotionEvent?: The first down motion event that started the scrolling. A null event indicates an incomplete event stream or error state.
e2 MotionEvent: The move motion event that triggered the current onScroll. This value cannot be null.
distanceX Float: The distance along the X axis that has been scrolled since the last call to onScroll. This is NOT the distance between e1 and e2.
distanceY Float: The distance along the Y axis that has been scrolled since the last call to onScroll. This is NOT the distance between e1 and e2.
Return
Boolean true if the event is consumed, else false

onShowPress

Added in API level 1
abstract fun onShowPress(e: MotionEvent): Unit

The user has performed a down MotionEvent and not performed a move or up yet. This event is commonly used to provide visual feedback to the user to let them know that their action has been recognized i.e. highlight an element.

Parameters
e MotionEvent: The down motion event This value cannot be null.

onSingleTapUp

Added in API level 1
abstract fun onSingleTapUp(e: MotionEvent): Boolean

Notified when a tap occurs with the up MotionEvent that triggered it.

Parameters
e MotionEvent: The up motion event that completed the first tap This value cannot be null.
Return
Boolean true if the event is consumed, else false