WearableDrawerView

public class WearableDrawerView

Known direct subclasses
WearableActionDrawerView

Ease of use class for creating a Wearable action drawer.

WearableNavigationDrawerView

Ease of use class for creating a Wearable navigation drawer.


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 {@code setter} methods on the {@code WearableDrawerView}, or by specifying the {@code app:drawerContent} and {@code * 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 final @NonNull int

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

static final @NonNull int

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

static final @NonNull int

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

Public constructors

WearableDrawerView(
    @NonNull Context context,
    @NonNull AttributeSet attrs,
    @NonNull int defStyleAttr
)
WearableDrawerView(
    @NonNull Context context,
    @NonNull AttributeSet attrs,
    @NonNull int defStyleAttr,
    @NonNull int defStyleRes
)

Public methods

@Override @NonNull void
addView(
    @NonNull View child,
    @NonNull int index,
    @NonNull ViewGroup.LayoutParams params
)
@NonNull WearableDrawerController

Returns the WearableDrawerController associated with this WearableDrawerView.

@Nullable View

Returns the drawer content view.

@WearableDrawerView.DrawerState @NonNull int

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

@NonNull boolean

Returns true if this drawer has auto-peeking enabled.

@NonNull boolean

Returns true if the drawer is fully closed.

@NonNull boolean

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

@NonNull boolean

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

@NonNull boolean

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

@NonNull boolean

Returns true if the drawer is fully open.

@NonNull boolean

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

@NonNull boolean

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

@NonNull void

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

@NonNull void

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

@NonNull void

Called when the drawer state changes.

@NonNull void

Called when anything within the peek container is clicked.

@NonNull void

Set the drawer content view.

@NonNull void
setIsAutoPeekEnabled(@NonNull boolean canAutoPeek)

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

@NonNull void
setIsLocked(@NonNull boolean locked)

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

@NonNull void
setLockedWhenClosed(@NonNull boolean locked)

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

@NonNull void
setOpenOnlyAtTopEnabled(@NonNull boolean openOnlyAtTop)

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

@NonNull void

Set the peek content view.

@NonNull void
setPeekOnScrollDownEnabled(@NonNull boolean peekOnScrollDown)

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

Inherited methods

From class FrameLayout
From class View
@NonNull void
@NonNull void
@NonNull void
@NonNull ViewPropertyAnimator
@NonNull void
@NonNull void
@NonNull void
@NonNull void

This method is deprecated.

@NonNull void
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
canScrollVertically(@NonNull int direction)
final @NonNull void
@NonNull void
final @NonNull void
@NonNull boolean
@NonNull void
static @NonNull int
combineMeasuredStates(@NonNull int curState, @NonNull int newState)
@NonNull void
@NonNull WindowInsets
computeSystemWindowInsets(
    @NonNull WindowInsets in,
    @NonNull Rect outLocalInsets
)
@NonNull AccessibilityNodeInfo
@NonNull void
@NonNull void

This method is deprecated.

@NonNull boolean
@NonNull boolean
dispatchNestedFling(
    @NonNull float velocityX,
    @NonNull float velocityY,
    @NonNull boolean consumed
)
@NonNull boolean
dispatchNestedPreFling(@NonNull float velocityX, @NonNull float velocityY)
@NonNull boolean
dispatchNestedPrePerformAccessibilityAction(
    @NonNull int action,
    @NonNull Bundle arguments
)
@NonNull boolean
dispatchNestedPreScroll(
    @NonNull int dx,
    @NonNull int dy,
    @NonNull Array<@NonNull int> consumed,
    @NonNull Array<@NonNull int> offsetInWindow
)
@NonNull boolean
dispatchNestedScroll(
    @NonNull int dxConsumed,
    @NonNull int dyConsumed,
    @NonNull int dxUnconsumed,
    @NonNull int dyUnconsumed,
    @NonNull Array<@NonNull int> offsetInWindow
)
@NonNull boolean
@NonNull void
draw(@NonNull Canvas canvas)
@NonNull void
drawableHotspotChanged(@NonNull float x, @NonNull float y)
final @NonNull T
<T extends View> findViewById(@NonNull int id)
final @NonNull T
<T extends View> findViewWithTag(@NonNull Object tag)
@NonNull void
forceHasOverlappingRendering(@NonNull boolean hasOverlappingRendering)
@NonNull void
static @NonNull int
@NonNull View.AccessibilityDelegate
@NonNull int
@NonNull AccessibilityNodeProvider
@NonNull CharSequence
@NonNull int
@NonNull int
@NonNull float
@NonNull Animation
@NonNull Matrix
@NonNull IBinder
@NonNull Array<@NonNull int>
@NonNull Map<@NonNull Integer, @NonNull Integer>
@NonNull Array<@NonNull String>
final @NonNull AutofillId
@NonNull int
@NonNull AutofillValue
@NonNull Drawable
@NonNull BlendMode
@NonNull ColorStateList
@NonNull PorterDuff.Mode
@NonNull int
final @NonNull int
@NonNull float
@NonNull Rect
@NonNull boolean
final @NonNull boolean
final @NonNull ContentCaptureSession
@NonNull CharSequence
final @NonNull Context
final @NonNull boolean
static @NonNull int
getDefaultSize(@NonNull int size, @NonNull int measureSpec)
@NonNull Display
final @NonNull Array<@NonNull int>
@NonNull Bitmap

This method is deprecated.

@NonNull int

This method is deprecated.

@NonNull int

This method is deprecated.

@NonNull void
@NonNull long
@NonNull float
@NonNull int
@NonNull boolean
@NonNull boolean
@NonNull int
@NonNull ArrayList<@NonNull View>
getFocusables(@NonNull int direction)
@NonNull void
@NonNull Drawable
@NonNull int
@NonNull BlendMode
@NonNull ColorStateList
@NonNull PorterDuff.Mode
@NonNull boolean
@NonNull Handler
final @NonNull boolean
final @NonNull int
@NonNull void
@NonNull int
@NonNull Drawable
@NonNull Drawable
@NonNull int
@NonNull int
@NonNull int
@NonNull int
@NonNull boolean
@NonNull KeyEvent.DispatcherState
@NonNull int
@NonNull int
@NonNull int
@NonNull ViewGroup.LayoutParams
final @NonNull int
final @NonNull boolean
@NonNull void
@NonNull void
@NonNull void
@NonNull Matrix
final @NonNull int
final @NonNull int
final @NonNull int
final @NonNull int
final @NonNull int
@NonNull int
@NonNull int
@NonNull int
@NonNull int
@NonNull int
@NonNull int
@NonNull int
@NonNull int
@NonNull View.OnFocusChangeListener
@NonNull int
@NonNull ViewOutlineProvider
@NonNull int
@NonNull int
@NonNull ViewOverlay
@NonNull int
@NonNull int
@NonNull int
@NonNull int
@NonNull int
@NonNull int
final @NonNull ViewParent
@NonNull ViewParent
@NonNull float
@NonNull float
@NonNull PointerIcon
@NonNull Resources
final @NonNull boolean
final @NonNull int
@NonNull View
@NonNull WindowInsets
@NonNull float
@NonNull float
@NonNull float
@NonNull float
@NonNull float
@NonNull int
@NonNull int
@NonNull int
@NonNull int
@NonNull int
final @NonNull int
final @NonNull int
@NonNull int
@NonNull int
final @NonNull CharSequence
@NonNull StateListAnimator
@NonNull List<@NonNull Rect>
@NonNull int

This method is deprecated.

@NonNull Object
@NonNull int
@NonNull int
@NonNull CharSequence
final @NonNull int
@NonNull TouchDelegate
@NonNull ArrayList<@NonNull View>
@NonNull float
@NonNull String
@NonNull float
@NonNull float
@NonNull float
@NonNull long
@NonNull int
@NonNull int
@NonNull Drawable
@NonNull Drawable
@NonNull int
@NonNull ViewTreeObserver
@NonNull int
final @NonNull int
@NonNull WindowId
@NonNull WindowInsetsController
@NonNull int

This method is deprecated.

@NonNull IBinder
@NonNull int
@NonNull void
@NonNull float
@NonNull float
@NonNull float
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
static @NonNull View
inflate(
    @NonNull Context context,
    @NonNull int resource,
    @NonNull ViewGroup root
)
@NonNull void

This method is deprecated.

@NonNull void
@NonNull void
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean

This method is deprecated.

@NonNull boolean
@NonNull boolean
final @NonNull boolean
final @NonNull boolean
@NonNull boolean
final @NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
final @NonNull boolean
final @NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
final @NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
final @NonNull boolean
@NonNull boolean
@NonNull boolean
final @NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull View
keyboardNavigationClusterSearch(
    @NonNull View currentCluster,
    @NonNull int direction
)
final @NonNull void
measure(@NonNull int widthMeasureSpec, @NonNull int heightMeasureSpec)
@NonNull void
@NonNull void
@NonNull WindowInsets
@NonNull void
@NonNull boolean
@NonNull boolean
@NonNull InputConnection
@NonNull boolean
@NonNull void
@NonNull boolean
@NonNull void
@NonNull boolean
@NonNull void
onHoverChanged(@NonNull boolean hovered)
@NonNull boolean
@NonNull void
@NonNull void
@NonNull boolean
onKeyDown(@NonNull int keyCode, @NonNull KeyEvent event)
@NonNull boolean
onKeyLongPress(@NonNull int keyCode, @NonNull KeyEvent event)
@NonNull boolean
onKeyMultiple(
    @NonNull int keyCode,
    @NonNull int repeatCount,
    @NonNull KeyEvent event
)
@NonNull boolean
onKeyPreIme(@NonNull int keyCode, @NonNull KeyEvent event)
@NonNull boolean
onKeyShortcut(@NonNull int keyCode, @NonNull KeyEvent event)
@NonNull boolean
onKeyUp(@NonNull int keyCode, @NonNull KeyEvent event)
@NonNull void
onPointerCaptureChange(@NonNull boolean hasCapture)
@NonNull void
@NonNull void
onProvideAutofillStructure(
    @NonNull ViewStructure structure,
    @NonNull int flags
)
@NonNull void
onProvideAutofillVirtualStructure(
    @NonNull ViewStructure structure,
    @NonNull int flags
)
@NonNull void
onProvideContentCaptureStructure(
    @NonNull ViewStructure structure,
    @NonNull int flags
)
@NonNull void
@NonNull void
@NonNull void
onRtlPropertiesChanged(@NonNull int layoutDirection)
@NonNull void
onScreenStateChanged(@NonNull int screenState)
@NonNull void
@NonNull boolean
@NonNull boolean
@NonNull void
onVisibilityAggregated(@NonNull boolean isVisible)
@NonNull void
onWindowFocusChanged(@NonNull boolean hasWindowFocus)
@NonNull void

This method is deprecated.

@NonNull boolean
performAccessibilityAction(@NonNull int action, @NonNull Bundle arguments)
@NonNull boolean
@NonNull boolean
performContextClick(@NonNull float x, @NonNull float y)
@NonNull boolean
performHapticFeedback(@NonNull int feedbackConstant)
@NonNull boolean
@NonNull void
playSoundEffect(@NonNull int soundConstant)
@NonNull boolean
@NonNull boolean
postDelayed(@NonNull Runnable action, @NonNull long delayMillis)
@NonNull void
@NonNull void
postInvalidateDelayed(@NonNull long delayMilliseconds)
@NonNull void
@NonNull void
@NonNull void
postOnAnimationDelayed(@NonNull Runnable action, @NonNull long delayMillis)
@NonNull void
@NonNull void
@NonNull boolean
@NonNull void
@NonNull void
@NonNull void
@NonNull void
@NonNull void

This method is deprecated.

final @NonNull boolean
@NonNull void
@NonNull void
@NonNull boolean
final @NonNull void
final @NonNull T
<T extends View> requireViewById(@NonNull int id)
@NonNull void
static @NonNull int
resolveSize(@NonNull int size, @NonNull int measureSpec)
static @NonNull int
resolveSizeAndState(
    @NonNull int size,
    @NonNull int measureSpec,
    @NonNull int childMeasuredState
)
@NonNull void
final @NonNull void
saveAttributeDataForStyleable(
    @NonNull Context context,
    @NonNull Array<@NonNull int> styleable,
    @NonNull AttributeSet attrs,
    @NonNull TypedArray t,
    @NonNull int defStyleAttr,
    @NonNull int defStyleRes
)
@NonNull void
@NonNull void
scheduleDrawable(
    @NonNull Drawable who,
    @NonNull Runnable what,
    @NonNull long when
)
@NonNull void
scrollBy(@NonNull int x, @NonNull int y)
@NonNull void
scrollTo(@NonNull int x, @NonNull int y)
@NonNull void
@NonNull void
@NonNull void
@NonNull void
setAccessibilityHeading(@NonNull boolean isHeading)
@NonNull void
@NonNull void
@NonNull void
@NonNull void
@NonNull void
setActivated(@NonNull boolean activated)
@NonNull void
setAlpha(@NonNull float alpha)
@NonNull void
@NonNull void
@NonNull void
@NonNull void
@NonNull void
@NonNull void
@NonNull void

This method is deprecated.

@NonNull void
@NonNull void
@NonNull void
@NonNull void
final @NonNull void
setBottom(@NonNull int bottom)
@NonNull void
setCameraDistance(@NonNull float distance)
@NonNull void
setClickable(@NonNull boolean clickable)
@NonNull void
setClipBounds(@NonNull Rect clipBounds)
@NonNull void
setClipToOutline(@NonNull boolean clipToOutline)
@NonNull void
setContentCaptureSession(
    @NonNull ContentCaptureSession contentCaptureSession
)
@NonNull void
@NonNull void
setContextClickable(@NonNull boolean contextClickable)
@NonNull void
setDefaultFocusHighlightEnabled(
    @NonNull boolean defaultFocusHighlightEnabled
)
@NonNull void

This method is deprecated.

@NonNull void
setDrawingCacheEnabled(@NonNull boolean enabled)

This method is deprecated.

@NonNull void

This method is deprecated.

@NonNull void
@NonNull void
setElevation(@NonNull float elevation)
@NonNull void
setEnabled(@NonNull boolean enabled)
@NonNull void
@NonNull void
@NonNull void
setFitsSystemWindows(@NonNull boolean fitSystemWindows)
@NonNull void
setFocusable(@NonNull boolean focusable)
@NonNull void
setFocusableInTouchMode(@NonNull boolean focusableInTouchMode)
@NonNull void
setFocusedByDefault(@NonNull boolean isFocusedByDefault)
@NonNull void
setForceDarkAllowed(@NonNull boolean allow)
@NonNull void
@NonNull void
@NonNull void
@NonNull void
@NonNull void
setHapticFeedbackEnabled(@NonNull boolean hapticFeedbackEnabled)
@NonNull void
setHasTransientState(@NonNull boolean hasTransientState)
@NonNull void
setHorizontalFadingEdgeEnabled(
    @NonNull boolean horizontalFadingEdgeEnabled
)
@NonNull void
setHorizontalScrollBarEnabled(
    @NonNull boolean horizontalScrollBarEnabled
)
@NonNull void
@NonNull void
@NonNull void
setHovered(@NonNull boolean hovered)
@NonNull void
setId(@NonNull int id)
@NonNull void
@NonNull void
@NonNull void
@NonNull void
setKeepScreenOn(@NonNull boolean keepScreenOn)
@NonNull void
@NonNull void
@NonNull void
@NonNull void
setLayerType(@NonNull int layerType, @NonNull Paint paint)
@NonNull void
setLayoutDirection(@NonNull int layoutDirection)
@NonNull void
final @NonNull void
setLeft(@NonNull int left)
final @NonNull void
setLeftTopRightBottom(
    @NonNull int left,
    @NonNull int top,
    @NonNull int right,
    @NonNull int bottom
)
@NonNull void
setLongClickable(@NonNull boolean longClickable)
@NonNull void
setMinimumHeight(@NonNull int minHeight)
@NonNull void
setMinimumWidth(@NonNull int minWidth)
@NonNull void
@NonNull void
setNextClusterForwardId(@NonNull int nextClusterForwardId)
@NonNull void
setNextFocusDownId(@NonNull int nextFocusDownId)
@NonNull void
setNextFocusForwardId(@NonNull int nextFocusForwardId)
@NonNull void
setNextFocusLeftId(@NonNull int nextFocusLeftId)
@NonNull void
setNextFocusRightId(@NonNull int nextFocusRig