Android 12 Developer Preview is here! Try it out, and give us your feedback!

DismissibleFrameLayout

public class DismissibleFrameLayout
extends FrameLayout

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ androidx.wear.widget.DismissibleFrameLayout


Special FrameLayout that is dismissible by the Back button press, and by left to right swipe when the SwipeToDismiss is been enabled on the device config or themes.

Summary

Nested classes

class DismissibleFrameLayout.Callback

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

Inherited constants

Inherited fields

Public constructors

DismissibleFrameLayout(Context context)

Simple constructor to use when creating a view from code.

DismissibleFrameLayout(Context context, AttributeSet attrs)

Constructor that is called when inflating a view from XML.

DismissibleFrameLayout(Context context, AttributeSet attrs, int defStyle)

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

DismissibleFrameLayout(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

boolean canScrollHorizontally(int direction)
boolean isBackButtonDismissible()

Returns true if the frame layout would be dismissed with back button click

boolean isSwipeDismissible()

Returns true if the frame layout can be dismissed by swipe gestures.

boolean onInterceptTouchEvent(MotionEvent ev)
boolean onTouchEvent(MotionEvent ev)
void registerCallback(DismissibleFrameLayout.Callback callback)

Registers a callback for dismissal.

void requestDisallowInterceptTouchEvent(boolean disallowIntercept)

Following methods overriding are only required with swipe-to-dismiss to handle touch event for detect swipe gesture.

void setBackButtonDismissible(boolean backButtonDismissible)

Sets the frame layout to be back button dismissible or not.

void setSwipeDismissible(boolean swipeDismissible)

Sets the frame layout to be swipe dismissible or not.

void unregisterCallback(DismissibleFrameLayout.Callback callback)

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

Protected methods

void executeDismissCanceledCallbacks()
void executeDismissStartedCallbacks()
void executeDismissedCallbacks()

Inherited methods

Public constructors

DismissibleFrameLayout

public DismissibleFrameLayout (Context context)

Simple constructor to use when creating a view from code.

Parameters
context Context: The Context the view is running in, through which it can access the current theme, resources, etc.

DismissibleFrameLayout

public DismissibleFrameLayout (Context context, 
                AttributeSet attrs)

Constructor that is called when inflating a view from XML. This is called when a view is being constructed from an XML file, supplying attributes that were specified in the XML file. This version uses a default style of 0, so the only attribute values applied are those in the Context's Theme and the given AttributeSet.

The method onFinishInflate() will be called after all children have been added.

Parameters
context Context: The Context the view is running in, through which it can access the current theme, resources, etc.

attrs AttributeSet: The attributes of the XML tag that is inflating the view.

DismissibleFrameLayout

public DismissibleFrameLayout (Context context, 
                AttributeSet attrs, 
                int defStyle)

Perform inflation from XML and apply a class-specific base style from a theme attribute. This constructor allows subclasses to use their own base style when they are inflating.

Parameters
context Context: The Context the view is running in, through which it can access the current theme, resources, etc.

attrs AttributeSet: The attributes of the XML tag that is inflating the view.

defStyle int: An attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults.

DismissibleFrameLayout

public DismissibleFrameLayout (Context context, 
                AttributeSet attrs, 
                int defStyle, 
                int defStyleRes)

Perform inflation from XML and apply a class-specific base style from a theme attribute. This constructor allows subclasses to use their own base style when they are inflating.

Parameters
context Context: The Context the view is running in, through which it can access the current theme, resources, etc.

attrs AttributeSet: The attributes of the XML tag that is inflating the view.

defStyle int: An attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults.

defStyleRes int: It allows a style resource to be specified when creating the view.

Public methods

canScrollHorizontally

public boolean canScrollHorizontally (int direction)

Parameters
direction int

Returns
boolean

isBackButtonDismissible

public boolean isBackButtonDismissible ()

Returns true if the frame layout would be dismissed with back button click

Returns
boolean

isSwipeDismissible

public boolean isSwipeDismissible ()

Returns true if the frame layout can be dismissed by swipe gestures.

Returns
boolean

onInterceptTouchEvent

public boolean onInterceptTouchEvent (MotionEvent ev)

Parameters
ev MotionEvent

Returns
boolean

onTouchEvent

public boolean onTouchEvent (MotionEvent ev)

Parameters
ev MotionEvent

Returns
boolean

registerCallback

public void registerCallback (DismissibleFrameLayout.Callback callback)

Registers a callback for dismissal.

Parameters
callback DismissibleFrameLayout.Callback

requestDisallowInterceptTouchEvent

public void requestDisallowInterceptTouchEvent (boolean disallowIntercept)

Following methods overriding are only required with swipe-to-dismiss to handle touch event for detect swipe gesture.

Parameters