WearableDrawerLayout

open class WearableDrawerLayout : FrameLayout, OnLayoutChangeListener, NestedScrollingParent, FlingListener
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ android.widget.FrameLayout
   ↳ androidx.wear.widget.drawer.WearableDrawerLayout

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 View#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 WearableDrawerView#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 classes
open

Listener for monitoring events about drawers.

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 Boolean

open Int

open Boolean
onNestedFling(@NonNull target: View, velocityX: Float, velocityY: Float, consumed: Boolean)

open Unit

open Unit
onNestedPreScroll(@NonNull target: View, dx: Int, dy: Int, @NonNull consumed: IntArray)

open Unit
onLayoutChange(v: View!, left: Int, top: Int, right: Int, bottom: Int, oldLeft: Int, oldTop: Int, oldRight: Int, oldBottom: Int)

open Unit
onStopNestedScroll(@NonNull target: View)

open WindowInsets!

open Unit

Sets a listener to be notified of drawer events.

open Boolean
onStartNestedScroll(@NonNull child: View, @NonNull target: View, nestedScrollAxes: Int)

open Unit

open Unit
onNestedScrollAccepted(@NonNull child: View, @NonNull target: View, nestedScrollAxes: Int)

open Unit
onNestedScroll(@NonNull target: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int)

open Boolean
onNestedPreFling(@NonNull target: View, velocityX: Float, velocityY: Float)

open Boolean

Protected methods
open Unit
onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int)

Public constructors

<init>

WearableDrawerLayout(context: Context!)

<init>

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

<init>

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

<init>

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

Public methods

addView

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

onTouchEvent

open fun onTouchEvent(ev: MotionEvent!): Boolean

getNestedScrollAxes

open fun getNestedScrollAxes(): Int

onNestedFling

open fun onNestedFling(@NonNull target: View, velocityX: Float, velocityY: Float, consumed: Boolean): Boolean

onFlingComplete

open fun onFlingComplete(view: View!): Unit

onNestedPreScroll

open fun onNestedPreScroll(@NonNull target: View, dx: Int, dy: Int, @NonNull consumed: IntArray): Unit

onLayoutChange

open fun onLayoutChange(v: View!, left: Int, top: Int, right: Int, bottom: Int, oldLeft: Int, oldTop: Int, oldRight: Int, oldBottom: Int): Unit

onStopNestedScroll

open fun onStopNestedScroll(@NonNull target: View): Unit

onApplyWindowInsets

open fun onApplyWindowInsets(insets: WindowInsets!): WindowInsets!

setDrawerStateCallback

open fun setDrawerStateCallback(callback: WearableDrawerLayout.DrawerStateCallback!): Unit

Sets a listener to be notified of drawer events.

onStartNestedScroll

open fun onStartNestedScroll(@NonNull child: View, @NonNull target: View, nestedScrollAxes: Int): Boolean

computeScroll

open fun computeScroll(): Unit

onNestedScrollAccepted

open fun onNestedScrollAccepted(@NonNull child: View, @NonNull target: View, nestedScrollAxes: Int): Unit

onNestedScroll

open fun onNestedScroll(@NonNull target: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int): Unit

onNestedPreFling

open fun onNestedPreFling(@NonNull target: View, velocityX: Float, velocityY: Float): Boolean

onInterceptTouchEvent

open fun onInterceptTouchEvent(ev: MotionEvent!): Boolean

Protected methods

onLayout

protected open fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int): Unit