added in version 26.1.0
belongs to Maven artifact com.android.support:wear:28.0.0-alpha1

WearableLinearLayoutManager

public class WearableLinearLayoutManager
extends LinearLayoutManager

java.lang.Object
   ↳ android.support.v7.widget.RecyclerView.LayoutManager
     ↳ android.support.v7.widget.LinearLayoutManager
       ↳ android.support.wear.widget.WearableLinearLayoutManager


This wear-specific implementation of LinearLayoutManager provides basic offsetting logic for updating child layout. For round devices it offsets the children horizontally to make them appear to travel around a circle. For square devices it aligns them in a straight list. This functionality is provided by the CurvingLayoutCallback which is set when constructing the this class with its default constructor WearableLinearLayoutManager(Context).

Summary

Nested classes

class WearableLinearLayoutManager.LayoutCallback

Callback for interacting with layout passes. 

Inherited XML attributes

From class android.support.v7.widget.LinearLayoutManager
From class android.support.v7.widget.RecyclerView.LayoutManager

Inherited constants

From class android.support.v7.widget.LinearLayoutManager

Public constructors

WearableLinearLayoutManager(Context context, WearableLinearLayoutManager.LayoutCallback layoutCallback)

Creates a WearableLinearLayoutManager for a vertical list.

WearableLinearLayoutManager(Context context)

Creates a WearableLinearLayoutManager for a vertical list.

Public methods

WearableLinearLayoutManager.LayoutCallback getLayoutCallback()
void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state)

Lay out all relevant child views from the given adapter.

int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state)

Scroll vertically by dy pixels in screen coordinates and return the distance traveled.

void setLayoutCallback(WearableLinearLayoutManager.LayoutCallback layoutCallback)

Set a particular instance of the layout callback for this WearableLinearLayoutManager.

Inherited methods

From class android.support.v7.widget.LinearLayoutManager
From class android.support.v7.widget.RecyclerView.LayoutManager
From class java.lang.Object
From interface android.support.v7.widget.helper.ItemTouchHelper.ViewDropHandler
From interface android.support.v7.widget.RecyclerView.SmoothScroller.ScrollVectorProvider

Public constructors

WearableLinearLayoutManager

added in version 26.1.0
WearableLinearLayoutManager (Context context, 
                WearableLinearLayoutManager.LayoutCallback layoutCallback)

Creates a WearableLinearLayoutManager for a vertical list.

Parameters
context Context: Current context, will be used to access resources.

layoutCallback WearableLinearLayoutManager.LayoutCallback: Callback to be associated with this WearableLinearLayoutManager

WearableLinearLayoutManager

added in version 26.1.0
WearableLinearLayoutManager (Context context)

Creates a WearableLinearLayoutManager for a vertical list.

Parameters
context Context: Current context, will be used to access resources.

Public methods

onLayoutChildren

added in version 26.1.0
void onLayoutChildren (RecyclerView.Recycler recycler, 
                RecyclerView.State state)

Lay out all relevant child views from the given adapter. The LayoutManager is in charge of the behavior of item animations. By default, RecyclerView has a non-null ItemAnimator, and simple item animations are enabled. This means that add/remove operations on the adapter will result in animations to add new or appearing items, removed or disappearing items, and moved items. If a LayoutManager returns false from supportsPredictiveItemAnimations(), which is the default, and runs a normal layout operation during onLayoutChildren(Recycler, State), the RecyclerView will have enough information to run those animations in a simple way. For example, the default ItemAnimator, DefaultItemAnimator, will simply fade views in and out, whether they are actually added/removed or whether they are moved on or off the screen due to other add/remove operations.

A LayoutManager wanting a better item animation experience, where items can be animated onto and off of the screen according to where the items exist when they are not on screen, then the LayoutManager should return true from supportsPredictiveItemAnimations() and add additional logic to onLayoutChildren(Recycler, State). Supporting predictive animations means that onLayoutChildren(Recycler, State) will be called twice; once as a "pre" layout step to determine where items would have been prior to a real layout, and again to do the "real" layout. In the pre-layout phase, items will remember their pre-layout positions to allow them to be laid out appropriately. Also, removed items will be returned from the scrap to help determine correct placement of other items. These removed items should not be added to the child list, but should be used to help calculate correct positioning of other views, including views that were not previously onscreen (referred to as APPEARING views), but whose pre-layout offscreen position can be determined given the extra information about the pre-layout removed views.

The second layout pass is the real layout in which only non-removed views will be used. The only additional requirement during this pass is, if supportsPredictiveItemAnimations() returns true, to note which views exist in the child list prior to layout and which are not there after layout (referred to as DISAPPEARING views), and to position/layout those views appropriately, without regard to the actual bounds of the RecyclerView. This allows the animation system to know the location to which to animate these disappearing views.

The default LayoutManager implementations for RecyclerView handle all of these requirements for animations already. Clients of RecyclerView can either use one of these layout managers directly or look at their implementations of onLayoutChildren() to see how they account for the APPEARING and DISAPPEARING views.

Parameters
recycler RecyclerView.Recycler: Recycler to use for fetching potentially cached views for a position

state RecyclerView.State: Transient state of RecyclerView

scrollVerticallyBy

added in version 26.1.0
int scrollVerticallyBy (int dy, 
                RecyclerView.Recycler recycler, 
                RecyclerView.State state)

Scroll vertically by dy pixels in screen coordinates and return the distance traveled. The default implementation does nothing and returns 0.

Parameters
dy int: distance to scroll in pixels. Y increases as scroll position approaches the bottom.

recycler RecyclerView.Recycler: Recycler to use for fetching potentially cached views for a position

state RecyclerView.State: Transient state of RecyclerView

Returns
int The actual distance scrolled. The return value will be negative if dy was negative and scrolling proceeeded in that direction. Math.abs(result) may be less than dy if a boundary was reached.

setLayoutCallback

added in version 26.1.0
void setLayoutCallback (WearableLinearLayoutManager.LayoutCallback layoutCallback)

Set a particular instance of the layout callback for this WearableLinearLayoutManager. The callback will be called on the Ui thread.