Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.

WearableDrawerLayout

public class WearableDrawerLayout
extends FrameLayout implements View.OnLayoutChangeListener, NestedScrollingParent

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ android.support.wearable.view.drawer.WearableDrawerLayout


This class is deprecated.
use the implementation provided by the Android Support Library Wear module instead.

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 NestedScrollingChild do this by default. To enable nested scrolling on frameworks views like ListView, set android:nestedScrollingEnabled="true" on the view in the layout file, or call setNestedScrollingEnabled(boolean) in code. This includes the main content in a WearableDrawerLayout, as well as the content inside of the drawers.

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

 <android.support.wearable.view.drawer.WearableDrawerLayout [...]>
     <FrameLayout
         android:id=”@+id/content” />

     <android.support.wearable.view.drawer.WearableNavigationDrawer
         android:layout_width=”match_parent”
         android:layout_height=”match_parent” />

     <android.support.wearable.view.drawer.WearableActionDrawer
         android:layout_width=”match_parent”
         android:layout_height=”match_parent” />

 </android.support.wearable.view.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(View) and pass in your drawer content view, or specify it in the app:drawer_content XML attribute.

 <android.support.wearable.view.drawer.WearableDrawerLayout [...]>
     <FrameLayout
         android:layout_width=”match_parent”
         android:layout_height=”match_parent”
         android:id=”@+id/content” />

     <android.support.wearable.view.drawer.WearableDrawerView
         android:layout_width=”match_parent”
         android:layout_height=”match_parent”
         android:layout_gravity=”top”
         app:drawer_content="@+id/top_drawer_content" >

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

     </android.support.wearable.view.drawer.WearableDrawerView>
 </android.support.wearable.view.drawer.WearableDrawerLayout>

Summary

Nested classes

class WearableDrawerLayout.DrawerStateCallback

Listener for monitoring events about drawers. 

Inherited constants

From class android.view.ViewGroup
From class android.view.View

Inherited fields

From class android.view.View

Public constructors

WearableDrawerLayout(Context context)
WearableDrawerLayout(Context context, AttributeSet attrs)
WearableDrawerLayout(Context context, AttributeSet attrs, int defStyleAttr)
WearableDrawerLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Public methods

void addView(View child, int index, ViewGroup.LayoutParams params)
void closeDrawer(View drawer)

Close the specified drawer by animating it out of view.

void closeDrawer(int gravity)

Close the specified drawer by animating it out of view.

void computeScroll()
int getNestedScrollAxes()
WindowInsets onApplyWindowInsets(WindowInsets insets)
void onFlingComplete(View view)
boolean onInterceptTouchEvent(MotionEvent ev)
void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom)
boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed)
boolean onNestedPreFling(View target, float velocityX, float velocityY)
void onNestedPreScroll(View target, int dx, int dy, int[] consumed)
void onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed)
void onNestedScrollAccepted(View child, View target, int nestedScrollAxes)
boolean onStartNestedScroll(View child, View target, int nestedScrollAxes)
void onStopNestedScroll(View target)
boolean onTouchEvent(MotionEvent ev)
void openDrawer(View drawer)

Open the specified drawer by animating it into view.

void openDrawer(int gravity)

Open the specified drawer by animating it into view.

void peekDrawer(WearableDrawerView drawer)

Peek the given WearableDrawerView, which may either be the top drawer or bottom drawer.

void peekDrawer(int gravity)

Peek the drawer.

void setDrawerStateCallback(WearableDrawerLayout.DrawerStateCallback callback)

Sets a listener to be notified of drawer events.

Protected methods

void onLayout(boolean changed, int left, int top, int right, int bottom)
void onSizeChanged(int w, int h, int oldw, int oldh)

Inherited methods

From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.view.ViewParent
From interface android.view.ViewManager
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource
From interface android.view.View.OnLayoutChangeListener
From interface android.support.v4.view.NestedScrollingParent

Public constructors

WearableDrawerLayout

WearableDrawerLayout (Context context)

Parameters
context Context

WearableDrawerLayout

WearableDrawerLayout (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

WearableDrawerLayout

WearableDrawerLayout (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

WearableDrawerLayout

WearableDrawerLayout (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

defStyleRes int

Public methods

addView

void addView (View child, 
                int index, 
                ViewGroup.LayoutParams params)

Parameters
child View

index int

params ViewGroup.LayoutParams

closeDrawer

void closeDrawer (View drawer)

Close the specified drawer by animating it out of view.

Parameters
drawer View: The drawer view to close.

closeDrawer

void closeDrawer (int gravity)

Close the specified drawer by animating it out of view.

Parameters
gravity int: Gravity.TOP to move the top drawer or Gravity.BOTTOM for the bottom.

computeScroll

void computeScroll ()

getNestedScrollAxes

int getNestedScrollAxes ()

Returns
int

onApplyWindowInsets

WindowInsets onApplyWindowInsets (WindowInsets insets)

Parameters
insets WindowInsets

Returns
WindowInsets

onFlingComplete

void onFlingComplete (View view)

Parameters
view View

onInterceptTouchEvent

boolean onInterceptTouchEvent (MotionEvent ev)

Parameters
ev MotionEvent

Returns
boolean

onLayoutChange

void onLayoutChange (View v, 
                int left, 
                int top, 
                int right, 
                int bottom, 
                int oldLeft, 
                int oldTop, 
                int oldRight, 
                int oldBottom)

Parameters
v View

left int

top int

right int

bottom int

oldLeft int

oldTop int

oldRight int

oldBottom int

onNestedFling

boolean onNestedFling (View target, 
                float velocityX, 
                float velocityY, 
                boolean consumed)

Parameters
target View

velocityX float

velocityY float

consumed boolean

Returns
boolean

onNestedPreFling

boolean onNestedPreFling (View target, 
                float velocityX, 
                float velocityY)

Parameters
target View

velocityX float

velocityY float

Returns
boolean

onNestedPreScroll

void onNestedPreScroll (View target, 
                int dx, 
                int dy, 
                int[] consumed)

Parameters
target View

dx int

dy int

consumed int

onNestedScroll

void onNestedScroll (View target, 
                int dxConsumed, 
                int dyConsumed, 
                int dxUnconsumed, 
                int dyUnconsumed)

Parameters
target View

dxConsumed int

dyConsumed int

dxUnconsumed int

dyUnconsumed int

onNestedScrollAccepted

void onNestedScrollAccepted (View child, 
                View target, 
                int nestedScrollAxes)

Parameters
child View

target View

nestedScrollAxes int

onStartNestedScroll

boolean onStartNestedScroll (View child, 
                View target, 
                int nestedScrollAxes)

Parameters
child View

target View

nestedScrollAxes int

Returns
boolean

onStopNestedScroll

void onStopNestedScroll (View target)

Parameters
target View

onTouchEvent

boolean onTouchEvent (MotionEvent ev)

Parameters
ev MotionEvent

Returns
boolean

openDrawer

void openDrawer (View drawer)

Open the specified drawer by animating it into view.

Parameters
drawer View: The drawer view to open.

openDrawer

void openDrawer (int gravity)

Open the specified drawer by animating it into view.

Parameters
gravity int: Gravity.TOP to move the top drawer or Gravity.BOTTOM for the bottom.

peekDrawer

void peekDrawer (WearableDrawerView drawer)

Peek the given WearableDrawerView, which may either be the top drawer or bottom drawer. This should only be used after the drawer has been added as a child of the WearableDrawerLayout.

Parameters
drawer WearableDrawerView

peekDrawer

void peekDrawer (int gravity)

Peek the drawer.

Parameters
gravity int: TOP to peek the top drawer or BOTTOM to peek the bottom drawer.

setDrawerStateCallback

void setDrawerStateCallback (WearableDrawerLayout.DrawerStateCallback callback)

Sets a listener to be notified of drawer events.

Parameters
callback WearableDrawerLayout.DrawerStateCallback

Protected methods

onLayout

void onLayout (boolean changed, 
                int left, 
                int top, 
                int right, 
                int bottom)

Parameters
changed boolean

left int

top int

right int

bottom int

onSizeChanged

void onSizeChanged (int w, 
                int h, 
                int oldw, 
                int oldh)

Parameters
w int

h int

oldw int

oldh int