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

WearableDrawerView

open class WearableDrawerView : FrameLayout
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ android.widget.FrameLayout
   ↳ androidx.wear.widget.drawer.WearableDrawerView

View that contains drawer content and a peeking view for use with WearableDrawerLayout.

This view provides the ability to set its main content as well as a view shown while peeking. Specifying the peek view is entirely optional; a default is used if none are set. However, the content must be provided.

There are two ways to specify the content and peek views: by invoking setter methods on the WearableDrawerView, or by specifying the app:drawerContent and app:peekView attributes. Examples:

// From Java:
  drawerView.setDrawerContent(drawerContentView);
  drawerView.setPeekContent(peekContentView);
 
  <!-- From XML: -->
  <androidx.wear.widget.drawer.WearableDrawerView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_gravity="bottom"
      android:background="@color/red"
      app:drawerContent="@+id/drawer_content"
      app:peekView="@+id/peek_view">
 
      <FrameLayout
          android:id="@id/drawer_content"
          android:layout_width="match_parent"
          android:layout_height="match_parent" />
 
      <LinearLayout
          android:id="@id/peek_view"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal"
          android:orientation="horizontal">
          <ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:src="@android:drawable/ic_media_play" />
          <ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:src="@android:drawable/ic_media_pause" />
      </LinearLayout>
  </androidx.wear.widget.drawer.WearableDrawerView>

Summary

Constants
static Int

Indicates that the drawer is currently being dragged by the user.

static Int

Indicates that the drawer is in an idle, settled state.

static Int

Indicates that the drawer is in the process of settling to a final position.

Public constructors
<init>(context: Context!)

<init>(context: Context!, attrs: AttributeSet!)

<init>(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

<init>(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

Public methods
open Unit
addView(child: View!, index: Int, params: LayoutParams!)

open WearableDrawerController!

Returns the WearableDrawerController associated with this WearableDrawerView.

open View?

Returns the drawer content view.

open Int

Returns the current drawer state, which will be one of STATE_DRAGGING, , or STATE_IDLE

open Boolean

Returns true if this drawer has auto-peeking enabled.

open Boolean

Returns true if the drawer is fully closed.

open Boolean

Returns true if the position of the drawer cannot be modified by user interaction.

open Boolean

Returns true if this drawer should be locked when the user cannot see it.

open Boolean

Returns whether this drawer may only be opened by the user when at the top of the scrolling content.

open Boolean

Returns true if the drawer is fully open.

open Boolean

Gets whether or not this drawer should peek while scrolling down.

open Boolean

Returns whether the drawer is either peeking or the peek view is animating open.

open Unit

Called when the drawer has settled in a completely closed state.

open Unit

Called when the drawer has settled in a completely open state.

open Unit

Called when the drawer state changes.

open Unit

Called when anything within the peek container is clicked.

open Unit
setDrawerContent(@Nullable content: View?)

Set the drawer content view.

open Unit

Sets whether or not the drawer can automatically adjust its peek state.

open Unit

Sets whether or not the position of the drawer can be modified by user interaction.

open Unit

Sets whether this drawer should be locked when the user cannot see it.

open Unit

Only allow the user to open this drawer when at the top of the scrolling content.

open Unit
setPeekContent(content: View!)

Set the peek content view.

open Unit

Sets whether or not this drawer should peek while scrolling down.

Protected methods
open Unit

open Unit

Constants

STATE_DRAGGING

static val STATE_DRAGGING: Int

Indicates that the drawer is currently being dragged by the user.

Value: ViewDragHelper.STATE_DRAGGING

STATE_IDLE

static val STATE_IDLE: Int

Indicates that the drawer is in an idle, settled state. No animation is in progress.

Value: ViewDragHelper.STATE_IDLE

STATE_SETTLING

static val STATE_SETTLING: Int

Indicates that the drawer is in the process of settling to a final position.

Value: ViewDragHelper.STATE_SETTLING

Public constructors

<init>

WearableDrawerView(context: Context!)

<init>

WearableDrawerView(
    context: Context!,
    attrs: AttributeSet!)

<init>

WearableDrawerView(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int)

<init>

WearableDrawerView(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int,
    defStyleRes: Int)

Public methods

addView

open fun addView(
    child: View!,
    index: Int,
    params: LayoutParams!
): Unit

getController

open fun getController(): WearableDrawerController!

Returns the WearableDrawerController associated with this WearableDrawerView. This will only be valid after this View has been added to its parent.

getDrawerContent

@Nullable open fun getDrawerContent(): View?

Returns the drawer content view.

getDrawerState

open fun getDrawerState(): Int

Returns the current drawer state, which will be one of STATE_DRAGGING, , or STATE_IDLE

isAutoPeekEnabled

open fun isAutoPeekEnabled(): Boolean

Returns true if this drawer has auto-peeking enabled. This will always return false for a locked drawer.

isClosed

open fun isClosed(): Boolean

Returns true if the drawer is fully closed.

isLocked

open fun isLocked(): Boolean

Returns true if the position of the drawer cannot be modified by user interaction. Specifically, a drawer cannot be opened, closed, or automatically peeked by . However, it can be explicitly opened, closed, and peeked by the developer. A drawer may be considered locked if the drawer is locked open, locked closed, or is closed and isLockedWhenClosed returns true.

isLockedWhenClosed

open fun isLockedWhenClosed(): Boolean

Returns true if this drawer should be locked when the user cannot see it.

See Also

isOpenOnlyAtTopEnabled

open fun isOpenOnlyAtTopEnabled():