Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.
added in version 1.0.0
belongs to Maven artifact androidx.wear:wear:1.0.0-rc01

WearableRecyclerView

public class WearableRecyclerView
extends RecyclerView

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ androidx.recyclerview.widget.RecyclerView
         ↳ androidx.wear.widget.WearableRecyclerView


Wearable specific implementation of the RecyclerView enabling setCircularScrollingGestureEnabled(boolean) circular scrolling} and semi-circular layouts.

Summary

Inherited XML attributes

Inherited constants

Inherited fields

Public constructors

WearableRecyclerView(Context context)
WearableRecyclerView(Context context, AttributeSet attrs)
WearableRecyclerView(Context context, AttributeSet attrs, int defStyle)
WearableRecyclerView(Context context, AttributeSet attrs, int defStyle, int defStyleRes)

Public methods

float getBezelFraction()

Returns the current bezel width for circular scrolling as a fraction of the screen's radius.

float getScrollDegreesPerScreen()

Returns how many degrees does the user have to rotate for to scroll through one screen height.

boolean isCircularScrollingGestureEnabled()

Returns whether circular scrolling is enabled for this view.

boolean isEdgeItemsCenteringEnabled()

Returns whether the view is currently configured to center the edge children.

boolean onTouchEvent(MotionEvent event)
void setBezelFraction(float fraction)

Taps within this radius and the radius of the screen are considered close enough to the bezel to be candidates for circular scrolling.

void setCircularScrollingGestureEnabled(boolean circularScrollingGestureEnabled)

Enables/disables circular touch scrolling for this view.

void setEdgeItemsCenteringEnabled(boolean isEnabled)

Use this method to configure the WearableRecyclerView to always align the first and last items with the vertical center of the screen.

void setScrollDegreesPerScreen(float degreesPerScreen)

Sets how many degrees the user has to rotate by to scroll through one screen height when they are using the circular scrolling gesture.The default value equates 180 degrees scroll to one screen.

Protected methods

void onAttachedToWindow()
void onDetachedFromWindow()

Inherited methods

Public constructors

WearableRecyclerView

added in version 1.0.0
public WearableRecyclerView (Context context)

Parameters
context Context

WearableRecyclerView

added in version 1.0.0
public WearableRecyclerView (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

WearableRecyclerView

added in version 1.0.0
public WearableRecyclerView (Context context, 
                AttributeSet attrs, 
                int defStyle)

Parameters
context Context

attrs AttributeSet

defStyle int

WearableRecyclerView

added in version 1.0.0
public WearableRecyclerView (Context context, 
                AttributeSet attrs, 
                int defStyle, 
                int defStyleRes)

Parameters
context Context

attrs AttributeSet

defStyle int

defStyleRes int

Public methods

getBezelFraction

added in version 1.0.0
public float getBezelFraction ()

Returns the current bezel width for circular scrolling as a fraction of the screen's radius.

Returns
float

getScrollDegreesPerScreen

added in version 1.0.0
public float getScrollDegreesPerScreen ()

Returns how many degrees does the user have to rotate for to scroll through one screen height.

Returns
float

isCircularScrollingGestureEnabled

added in version 1.0.0
public boolean isCircularScrollingGestureEnabled ()

Returns whether circular scrolling is enabled for this view.

Returns
boolean

isEdgeItemsCenteringEnabled

added in version 1.0.0
public boolean isEdgeItemsCenteringEnabled ()

Returns whether the view is currently configured to center the edge children. See setEdgeItemsCenteringEnabled(boolean) for details.

Returns
boolean

onTouchEvent

public boolean onTouchEvent (MotionEvent event)

Parameters
event MotionEvent

Returns
boolean

setBezelFraction

added in version 1.0.0
public void setBezelFraction (float fraction)

Taps within this radius and the radius of the screen are considered close enough to the bezel to be candidates for circular scrolling. Expressed as a fraction of the screen's radius. The default is the whole screen i.e 1.0f.

Parameters
fraction float

setCircularScrollingGestureEnabled

added in version 1.0.0
public void setCircularScrollingGestureEnabled (boolean circularScrollingGestureEnabled)

Enables/disables circular touch scrolling for this view. When enabled, circular touch gestures around the edge of the screen will cause the view to scroll up or down. Related methods let you specify the characteristics of the scrolling, like the speed of the scroll or the are considered for the start of this scrolling gesture.

Parameters
circularScrollingGestureEnabled boolean

setEdgeItemsCenteringEnabled

added in version 1.0.0
public void setEdgeItemsCenteringEnabled (boolean isEnabled)

Use this method to configure the WearableRecyclerView to always align the first and last items with the vertical center of the screen. This effectively moves the start and end of the list to the middle of the screen if the user has scrolled so far. It takes the height of the children into account so that they are correctly centered.

Parameters
isEnabled boolean: set to true if you wish to align the edge children (first and last) with the center of the screen.

setScrollDegreesPerScreen

added in version 1.0.0
public void setScrollDegreesPerScreen (float degreesPerScreen)

Sets how many degrees the user has to rotate by to scroll through one screen height when they are using the circular scrolling gesture.The default value equates 180 degrees scroll to one screen.

Parameters
degreesPerScreen float: the number of degrees to rotate by to scroll through one whole height of the screen,

Protected methods

onAttachedToWindow

protected void onAttachedToWindow ()

onDetachedFromWindow

protected void onDetachedFromWindow ()