SwipeDismissTouchListener

A android.view.View.OnTouchListener that makes any android.view.View dismissable when the user swipes (drags her finger) horizontally across the view. Optionally supports vertical swipe dismissal in a single configured direction (up or down).

For android.widget.ListView list items that don't manage their own touch events (i.e. you're using setOnItemClickListener or an equivalent listener on android.app.ListActivity or android.app.ListFragment, use SwipeDismissListViewTouchListener instead.

Example usage:

view.setOnTouchListener(new SwipeDismissTouchListener(
        view,
        null, // Optional token/cookie object
        new SwipeDismissTouchListener.OnDismissCallback() {
            public void onDismiss(View view, Object token) {
                parent.removeView(view);
            }
        }));

This class Requires API level 12 or later due to use of android.view.ViewPropertyAnimator.

See also

SwipeDismissListViewTouchListener

Inheritors

Constructors

Link copied to clipboard
constructor(view: View, token: Any, callbacks: SwipeDismissTouchListener.DismissCallbacks)
Constructs a new swipe-to-dismiss touch listener for the given view with horizontal-only dismissal.
constructor(view: View, token: Any, callbacks: SwipeDismissTouchListener.DismissCallbacks, verticalDismissDirection: SwipeDismissTouchListener.VerticalDismissDirection)
Constructs a new swipe-to-dismiss touch listener for the given view.

Types

Link copied to clipboard
The callback interface used by SwipeDismissTouchListener to inform its client about a successful dismissal of the view for which it was created.
Link copied to clipboard
Specifies which vertical swipe direction, if any, should trigger a dismiss.

Functions

Link copied to clipboard
open fun onTouch(view: View, motionEvent: MotionEvent): Boolean
Link copied to clipboard
open fun performDismiss()
Animates the dismissed view to zero-height and then fires the dismiss callback.