WearableDrawerView

Added in 1.1.0

public class WearableDrawerView extends FrameLayout

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 setter methods on the WearableDrawerView, or by specifying the app:drawerContent and 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 int

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

static final int

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

static final int

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

Public constructors

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

Public methods

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

Returns the WearableDrawerController associated with this WearableDrawerView.

@Nullable View

Returns the drawer content view.

int

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

boolean

Returns true if this drawer has auto-peeking enabled.

boolean

Returns true if the drawer is fully closed.

boolean

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

boolean

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

boolean

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

boolean

Returns true if the drawer is fully open.

boolean

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

boolean

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

void

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

void

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

void

Called when the drawer state changes.

void

Called when anything within the peek container is clicked.

void

Set the drawer content view.

void
setIsAutoPeekEnabled(boolean canAutoPeek)

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

void
setIsLocked(boolean locked)

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

void
setLockedWhenClosed(boolean locked)

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

void
setOpenOnlyAtTopEnabled(boolean openOnlyAtTop)

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

void

Set the peek content view.

void
setPeekOnScrollDownEnabled(boolean peekOnScrollDown)

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

Protected methods

void
void

Inherited Constants

From android.view.View
static final int
static final int
static final int
static final int
static final int
static final int
static final Property<ViewFloat>
static final int
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = "creditCardExpirationDate"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = "creditCardExpirationDay"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = "creditCardExpirationMonth"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = "creditCardExpirationYear"
static final String
static final String
AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = "creditCardSecurityCode"
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int[]
static final int[]
static final int[]
static final int[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int
GONE = 8
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
KEEP_SCREEN_ON = 67108864
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
NO_ID = -1
static final int
static final int
static final int
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final float
static final float
static final float
static final float
static final float
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int[]
static final int[]
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final String
VIEW_LOG_TAG = "View"
static final int
static final int[]
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
From android.view.ViewGroup
static final int
static final int
static final int
static final int
static final int
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

Inherited methods

From android.widget.FrameLayout
boolean
FrameLayout.LayoutParams
FrameLayout.LayoutParams
CharSequence
boolean

This method is deprecated.

boolean
void
onLayout(boolean changed, int left, int top, int right, int bottom)
void
onMeasure(int widthMeasureSpec, int heightMeasureSpec)
void
setForegroundGravity(int foregroundGravity)
void
setMeasureAllChildren(boolean measureAll)
boolean
From android.view.View
void
void
void
ViewPropertyAnimator
void

This method is deprecated.

void
boolean
void
void

This method is deprecated.

void
boolean
boolean
boolean
boolean
boolean
canScrollHorizontally(int direction)
boolean
canScrollVertically(int direction)
final void
void
final void
boolean
void
void
void
static int
combineMeasuredStates(int curState, int newState)
int
int
int
void
WindowInsets
int
int
int
AccessibilityNodeInfo
void
void

This method is deprecated.

boolean
boolean
dispatchNestedFling(float velocityX, float velocityY, boolean consumed)
boolean
dispatchNestedPreFling(float velocityX, float velocityY)
boolean
dispatchNestedPrePerformAccessibilityAction(
    int action,
    Bundle arguments
)