Stay organized with collections Save and categorize content based on your preferences.
added in version 26.1.0
belongs to Maven artifact


public class SwipeDismissFrameLayout
extends FrameLayout

   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout

A layout enabling left-to-right swipe-to-dismiss, intended for use within an activity.

At least one listener must be added to act on a dismissal action. A listener will typically remove a containing view or fragment from the current activity.

To suppress a swipe-dismiss gesture, at least one contained view must be scrollable, indicating that it would like to consume any horizontal touch gestures in that direction. In this case this view will only allow swipe-to-dismiss on the very edge of the left-hand-side of the screen. If you wish to entirely disable the swipe-to-dismiss gesture, setSwipeable(boolean) can be used for more direct control over the feature.


Nested classes

class SwipeDismissFrameLayout.Callback

Implement this callback to act on particular stages of the dismissal. 



Inherited constants

From class android.view.ViewGroup
From class android.view.View

Inherited fields

From class android.view.View

Public constructors

SwipeDismissFrameLayout(Context context)

Simple constructor to use when creating a view from code.

SwipeDismissFrameLayout(Context context, AttributeSet attrs)

Constructor that is called when inflating a view from XML.

SwipeDismissFrameLayout(Context context, AttributeSet attrs, int defStyle)

Perform inflation from XML and apply a class-specific base style from a theme attribute.

SwipeDismissFrameLayout(Context context, AttributeSet attrs, int defStyle, int defStyleRes)

Perform inflation from XML and apply a class-specific base style from a theme attribute.

Public methods

void addCallback(SwipeDismissFrameLayout.Callback callback)

Adds a callback for dismissal.

boolean canScrollHorizontally(int direction)
float getDismissMinDragWidthRatio()

Returns the current ratio of te screen at which the swipe gesture is treated as swipe-to-dismiss.

boolean isSwipeable()

Returns true if the layout reacts to swipe gestures.

boolean onInterceptTouchEvent(MotionEvent ev)
boolean onTouchEvent(MotionEvent ev)
void removeCallback(SwipeDismissFrameLayout.Callback callback)

Removes a callback that was added with addCallback(Callback).

void requestDisallowInterceptTouchEvent(boolean disallowIntercept)
void setDismissMinDragWidthRatio(float ratio)

Sets the minimum ratio of the screen after which the swipe gesture is treated as swipe-to- dismiss.

void setSwipeable(boolean swipeable)

Sets the layout to swipeable or not.

Protected methods

boolean canScroll(View v, boolean checkV, float dx, float x, float y)

Tests scrollability within child views of v in the direction of dx.

Inherited methods

From class android.widget.FrameLayout
From class android.view.ViewGroup