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 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(
    Context context,
    AttributeSet attrs,
    int defStyleAttr
)
WearableDrawerLayout(
    Context context,
    AttributeSet attrs,
    int defStyleAttr,
    int defStyleRes
)

Public methods

@Override void
addView(View child, int index, ViewGroup.LayoutParams params)
@Override void
@Override int
@Override WindowInsets
@Override void
@Override boolean
@Override void
onLayoutChange(
    View v,
    int left,
    int top,
    int right,
    int bottom,
    int oldLeft,
    int oldTop,
    int oldRight,
    int oldBottom
)
@Override boolean
onNestedFling(
    @NonNull View target,
    float velocityX,
    float velocityY,
    boolean consumed
)
@Override boolean
onNestedPreFling(@NonNull View target, float velocityX, float velocityY)
@Override void
onNestedPreScroll(@NonNull View target, int dx, int dy, int[] consumed)
@Override void
onNestedScroll(
    @NonNull View target,
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed
)
@Override void
onNestedScrollAccepted(@NonNull View child, @NonNull View target, int axes)
@Override boolean
onStartNestedScroll(
    @NonNull View child,
    @NonNull View target,
    int nestedScrollAxes
)
@Override void
@Override boolean
void

Sets a listener to be notified of drawer events.