Google is committed to advancing racial equity for Black communities. See how.

DismissibleFrameLayout

@UiThread open class DismissibleFrameLayout : FrameLayout
kotlin.Any
   ↳ 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
abstract

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

Public constructors
<init>(@NonNull context: Context)

Simple constructor to use when creating a view from code.

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?)

Constructor that is called when inflating a view from XML.

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?, defStyle: Int)

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

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?, defStyle: Int, defStyleRes: Int)

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

Public methods
open Boolean

open Boolean

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

open Boolean

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

open Boolean

open Boolean
onTouchEvent(@NonNull ev: MotionEvent)

open Unit

Registers a callback for dismissal.

open Unit

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

open Unit
setBackButtonDismissible(backButtonDismissible: Boolean)

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

open Unit
setSwipeDismissible(swipeDismissible: Boolean)

Sets the frame layout to be swipe dismissible or not.

open Unit

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

Protected methods
open Unit

open Unit

open Unit

Public constructors

<init>

DismissibleFrameLayout(@NonNull 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.

<init>

DismissibleFrameLayout(
    @NonNull context: Context,
    @Nullable attrs: AttributeSet?)

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.

<init>

DismissibleFrameLayout(
    @NonNull context: Context,
    @Nullable attrs: AttributeSet?,
    defStyle: Int)

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.

<init>

DismissibleFrameLayout(
    @NonNull context: Context,
    @Nullable attrs: AttributeSet?,
    defStyle: Int,
    defStyleRes: Int)

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

open fun canScrollHorizontally(direction: Int): Boolean

isBackButtonDismissible

open fun isBackButtonDismissible(): Boolean

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

isSwipeDismissible

open fun isSwipeDismissible(): Boolean

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

onInterceptTouchEvent

open fun onInterceptTouchEvent(@NonNull ev: MotionEvent): Boolean

onTouchEvent

open fun onTouchEvent(@NonNull ev: MotionEvent): Boolean

registerCallback

@UiThread open fun registerCallback(@NonNull callback: DismissibleFrameLayout.Callback): Unit

Registers a callback for dismissal.

requestDisallowInterceptTouchEvent

open fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean): Unit

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

setBackButtonDismissible

open fun setBackButtonDismissible(backButtonDismissible: Boolean): Unit

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

Parameters
backButtonDismissible Boolean: boolean value to enable/disable the back button dismiss

setSwipeDismissible

open fun setSwipeDismissible(swipeDismissible: Boolean): Unit

Sets the frame layout to be swipe dismissible or not.

Parameters
swipeDismissible Boolean: whether the layout should react to the swipe gesture

unregisterCallback

@UiThread open fun unregisterCallback(@NonNull callback: DismissibleFrameLayout.Callback): Unit

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

Protected methods

executeDismissCanceledCallbacks

protected open fun executeDismissCanceledCallbacks(): Unit

executeDismissStartedCallbacks

protected open fun executeDismissStartedCallbacks(): Unit