WearableDrawerLayout

public class WearableDrawerLayout implements NestedScrollingParent


Top-level container that allows interactive drawers to be pulled from the top and bottom edge of the window. For WearableDrawerLayout to work properly, scrolling children must send nested scrolling events. Views that implement androidx.core.view.NestedScrollingChild do this by default. To enable nested scrolling on frameworks views like , set android:nestedScrollingEnabled="true" on the view in the layout file, or call setNestedScrollingEnabled in code. This includes the main content in a WearableDrawerLayout, as well as the content inside of the drawers.

To use WearableDrawerLayout with WearableActionDrawerView or , place either drawer in a WearableDrawerLayout.

<androidx.wear.widget.drawer.WearableDrawerLayout [...]>
    <FrameLayout android:id=”@+id/content” />

    <androidx.wear.widget.drawer.WearableNavigationDrawerView
        android:layout_width=”match_parent”
        android:layout_height=”match_parent” />

    <androidx.wear.widget.drawer.WearableActionDrawerView
        android:layout_width=”match_parent”
        android:layout_height=”match_parent” />

</androidx.wear.widget.drawer.WearableDrawerLayout>

To use custom content in a drawer, place WearableDrawerView in a WearableDrawerLayout and specify the layout_gravity to pick the drawer location (the following example is for a top drawer). Note: You must either call setDrawerContent and pass in your drawer content view, or specify it in the {@code app:drawerContent} XML attribute.

<androidx.wear.widget.drawer.WearableDrawerLayout [...]>
    <FrameLayout
        android:id=”@+id/content”
        android:layout_width=”match_parent”
        android:layout_height=”match_parent” />

    <androidx.wear.widget.drawer.WearableDrawerView
        android:layout_width=”match_parent”
        android:layout_height=”match_parent”
        android:layout_gravity=”top”
        app:drawerContent="@+id/top_drawer_content" >

        <FrameLayout
            android:id=”@id/top_drawer_content”
            android:layout_width=”match_parent”
            android:layout_height=”match_parent” />

    </androidx.wear.widget.drawer.WearableDrawerView>
</androidx.wear.widget.drawer.WearableDrawerLayout>

Summary

Nested types

WearableDrawerLayout.DrawerStateCallback

Listener for monitoring events about drawers.

Public constructors

WearableDrawerLayout(
    @NonNull Context context,
    @NonNull AttributeSet attrs,
    @NonNull int defStyleAttr
)
WearableDrawerLayout(
    @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
)
@Override @NonNull void
@Override @NonNull int
@Override @NonNull WindowInsets
@Override @NonNull void
@Override @NonNull boolean
@Override @NonNull void
onLayoutChange(
    @NonNull View v,
    @NonNull int left,
    @NonNull int top,
    @NonNull int right,
    @NonNull int bottom,
    @NonNull int oldLeft,
    @NonNull int oldTop,
    @NonNull int oldRight,
    @NonNull int oldBottom
)
@Override @NonNull boolean
onNestedFling(
    @NonNull View target,
    @NonNull float velocityX,
    @NonNull float velocityY,
    @NonNull boolean consumed
)
@Override @NonNull boolean
onNestedPreFling(
    @NonNull View target,
    @NonNull float velocityX,
    @NonNull float velocityY
)
@Override @NonNull void
onNestedPreScroll(
    @NonNull View target,
    @NonNull int dx,
    @NonNull int dy,
    @NonNull Array<@NonNull int> consumed
)
@Override @NonNull void
onNestedScroll(
    @NonNull View target,
    @NonNull int dxConsumed,
    @NonNull int dyConsumed,
    @NonNull int dxUnconsumed,
    @NonNull int dyUnconsumed
)
@Override @NonNull void
onNestedScrollAccepted(
    @NonNull View child,
    @NonNull View target,
    @NonNull int axes
)
@Override @NonNull boolean
onStartNestedScroll(
    @NonNull View child,
    @NonNull View target,
    @NonNull int nestedScrollAxes
)
@Override @NonNull void
@Override @NonNull boolean
@NonNull void

Sets a listener to be notified of drawer events.

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
@NonNull void
static @NonNull int
combineMeasuredStates(@NonNull int curState, @NonNull int newState)
@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