DismissOverlayView

public class DismissOverlayView
extends FrameLayout

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ android.support.wearable.view.DismissOverlayView


A view for implementing long-press-to-dismiss in an app.

DismissOverlayView should be added to your layout such that it draws full-screen and over all other views. To use it, set the intro text using setIntroText(CharSequence) and call showIntroIfNecessary() in your activity's onCreate (or your fragment's onCreateView). Then, use a GestureDetector in your activity to detect long press gestures; when one is found, call show() on your DismissOverlayView. DismissOverlayView takes care of all of the hiding, showing, and dismissal logic for you; setting its visibility or alpha may lead to unintended behavior.

Summary

Inherited constants

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

Inherited fields

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

Public constructors

DismissOverlayView(Context context)
DismissOverlayView(Context context, AttributeSet attrs)
DismissOverlayView(Context context, AttributeSet attrs, int defStyle)

Public methods

boolean performClick()
void setIntroText(int textResId)

Set the intro text.

void setIntroText(CharSequence str)

Set the intro text.

void show()

Show the exit button.

void showIntroIfNecessary()

Displays the intro overlay over your app if necessary.

Inherited methods

From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.view.ViewParent
From interface android.view.ViewManager
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

Public constructors

DismissOverlayView

DismissOverlayView (Context context)

Parameters
context Context

DismissOverlayView

DismissOverlayView (Context context,
                AttributeSet attrs)

Parameters
context Context
attrs AttributeSet

DismissOverlayView

DismissOverlayView (Context context,
                AttributeSet attrs,
                int defStyle)

Parameters
context Context
attrs AttributeSet
defStyle int

Public methods

performClick

boolean performClick ()

Returns
boolean

setIntroText

void setIntroText (int textResId)

Set the intro text. The intro text is the text displayed when the app is run for the first time, as an overlay on the rest of your app's content.

Parameters
textResId int

setIntroText

void setIntroText (CharSequence str)

Set the intro text. The intro text is the text displayed when the app is run for the first time, as an overlay on the rest of your app's content.

Parameters
str CharSequence

show

void show ()

Show the exit button. This should be called from a long-press listener.

showIntroIfNecessary

void showIntroIfNecessary ()

Displays the intro overlay over your app if necessary. This does nothing if no intro text has been set, or if this is not the first time showIntroIfNecessary is called for your app.