WearableDrawerView
class WearableDrawerView : FrameLayout
| kotlin.Any | ||||
| ↳ | android.view.View | |||
| ↳ | android.view.ViewGroup | |||
| ↳ | android.widget.FrameLayout | |||
| ↳ | androidx.wear.widget.drawer.WearableDrawerView |
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 |
|
|---|---|
const Int |
STATE_DRAGGING = 1Indicates that the drawer is currently being dragged by the user. |
const Int |
STATE_IDLE = 0Indicates that the drawer is in an idle, settled state. |
const Int |
STATE_SETTLING = 2Indicates that the drawer is in the process of settling to a final position. |
Public constructors |
|---|
WearableDrawerView(context: Context!) |
WearableDrawerView(context: Context!, attrs: AttributeSet!) |
WearableDrawerView( |
WearableDrawerView( |
Public functions |
|
|---|---|
Unit |
addView(child: View!, index: Int, params: ViewGroup.LayoutParams!) |
WearableDrawerController! |
Returns the |
View? |
Returns the drawer content view. |
Int |
Returns the current drawer state, which will be one of |
Boolean |
Returns true if this drawer has auto-peeking enabled. |
Boolean |
isClosed()Returns true if the drawer is fully closed. |
Boolean |
isLocked()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 |
isOpened()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. |
Unit |
Called when the drawer has settled in a completely closed state. |
Unit |
Called when the drawer has settled in a completely open state. |
Unit |
onDrawerStateChanged(state: Int)Called when the drawer state changes. |
Unit |
Called when anything within the peek container is clicked. |
Unit |
setDrawerContent(content: View?)Set the drawer content view. |
Unit |
setIsAutoPeekEnabled(canAutoPeek: Boolean)Sets whether or not the drawer can automatically adjust its peek state. |
Unit |
setIsLocked(locked: Boolean)Sets whether or not the position of the drawer can be modified by user interaction. |
Unit |
setLockedWhenClosed(locked: Boolean)Sets whether this drawer should be locked when the user cannot see it. |
Unit |
setOpenOnlyAtTopEnabled(openOnlyAtTop: Boolean)Only allow the user to open this drawer when at the top of the scrolling content. |
Unit |
setPeekContent(content: View!)Set the peek content view. |
Unit |
setPeekOnScrollDownEnabled(peekOnScrollDown: Boolean)Sets whether or not this drawer should peek while scrolling down. |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Constants
STATE_DRAGGING
const val STATE_DRAGGING = 1: Int
Indicates that the drawer is currently being dragged by the user.
STATE_IDLE
const val STATE_IDLE = 0: Int
Indicates that the drawer is in an idle, settled state. No animation is in progress.
STATE_SETTLING
const val STATE_SETTLING = 2: Int
Indicates that the drawer is in the process of settling to a final position.
Public constructors
WearableDrawerView
WearableDrawerView(
context: Context!,
attrs: AttributeSet!,
defStyleAttr: Int
)
WearableDrawerView
WearableDrawerView(
context: Context!,
attrs: AttributeSet!,
defStyleAttr: Int,
defStyleRes: Int
)
Public functions
getController
fun getController(): WearableDrawerController!
Returns the WearableDrawerController associated with this WearableDrawerView. This will only be valid after this View has been added to its parent.
getDrawerState
fun getDrawerState(): Int
Returns the current drawer state, which will be one of STATE_DRAGGING, STATE_SETTLING, or STATE_IDLE
isAutoPeekEnabled
fun isAutoPeekEnabled(): Boolean
Returns true if this drawer has auto-peeking enabled. This will always return false for a locked drawer.
isLocked
fun isLocked(): Boolean
Returns true if the position of the drawer cannot be modified by user interaction. Specifically, a drawer cannot be opened, closed, or automatically peeked by WearableDrawerLayout. However, it can be explicitly opened, closed, and peeked by the developer. A drawer may be considered locked if the drawer is locked open, locked closed, or is closed and isLockedWhenClosed returns true.
isLockedWhenClosed
fun isLockedWhenClosed(): Boolean
Returns true if this drawer should be locked when the user cannot see it.
| See also | |
|---|---|
isLocked |
isOpenOnlyAtTopEnabled
fun isOpenOnlyAtTopEnabled(): Boolean
Returns whether this drawer may only be opened by the user when at the top of the scrolling content. If there is no scrolling content, then this has no effect. Defaults to
false.
isPeekOnScrollDownEnabled
fun isPeekOnScrollDownEnabled(): Boolean
Gets whether or not this drawer should peek while scrolling down. This is currently only supported for bottom drawers. Defaults to false.
isPeeking
fun isPeeking(): Boolean
Returns whether the drawer is either peeking or the peek view is animating open.
onDrawerClosed
fun onDrawerClosed(): Unit
Called when the drawer has settled in a completely closed state. This is analogous to onDrawerClosed.
onDrawerOpened
fun onDrawerOpened(): Unit
Called when the drawer has settled in a completely open state. The drawer is interactive at this point. This is analogous to onDrawerOpened.
onDrawerStateChanged
fun onDrawerStateChanged(state: Int): Unit
Called when the drawer state changes. This is analogous to onDrawerStateChanged.
| Parameters | |
|---|---|
state: Int |
one of |
onPeekContainerClicked
fun onPeekContainerClicked(v: View!): Unit
Called when anything within the peek container is clicked. However, if a custom peek view is supplied and it handles the click, then this may not be called. The default behavior is to open the drawer.
setDrawerContent
fun setDrawerContent(content: View?): Unit
Set the drawer content view.
| Parameters | |
|---|---|
content: View? |
The view to show when the drawer is open, or |
setIsAutoPeekEnabled
fun setIsAutoPeekEnabled(canAutoPeek: Boolean): Unit
Sets whether or not the drawer can automatically adjust its peek state. Note that locked drawers will never auto-peek, but their isAutoPeekEnabled state will be maintained through a lock/unlock cycle.
setIsLocked
fun setIsLocked(locked: Boolean): Unit
Sets whether or not the position of the drawer can be modified by user interaction.
| See also | |
|---|---|
isLocked |
setLockedWhenClosed
fun setLockedWhenClosed(locked: Boolean): Unit
Sets whether this drawer should be locked when the user cannot see it.
| See also | |
|---|---|
isLocked |
setOpenOnlyAtTopEnabled
fun setOpenOnlyAtTopEnabled(openOnlyAtTop: Boolean): Unit
Only allow the user to open this drawer when at the top of the scrolling content. If there is no scrolling content, then this has no effect. Defaults to false.
setPeekContent
fun setPeekContent(content: View!): Unit
Set the peek content view.
| Parameters | |
|---|---|
content: View! |
The view to show when the drawer peeks. |
setPeekOnScrollDownEnabled
fun setPeekOnScrollDownEnabled(peekOnScrollDown: Boolean): Unit
Sets whether or not this drawer should peek while scrolling down. This is currently only supported for bottom drawers. Defaults to false.