public class WrapLayoutManager extends RecyclerView.LayoutManager
RecyclerView.LayoutManager
implementation that starts the layout of items on one line
until space is available. When the is no space on the current line to accommodate the next item
a new line is created and the layout process continues there.RecyclerView.LayoutManager.Properties
Modifier and Type | Field and Description |
---|---|
static int |
HORIZONTAL |
static int |
VERTICAL |
Constructor and Description |
---|
WrapLayoutManager(Context context)
Creates an instance of the
WrapLayoutManager class. |
WrapLayoutManager(Context context,
AttributeSet attrs,
int defStyleAttr,
int defStyleRes)
Creates an instance of the
WrapLayoutManager class. |
WrapLayoutManager(Context context,
int orientation)
Creates an instance of the
WrapLayoutManager class. |
Modifier and Type | Method and Description |
---|---|
boolean |
canScrollHorizontally() |
boolean |
canScrollVertically() |
int |
computeHorizontalScrollExtent(RecyclerView.State state) |
int |
computeHorizontalScrollOffset(RecyclerView.State state) |
int |
computeHorizontalScrollRange(RecyclerView.State state) |
int |
computeVerticalScrollExtent(RecyclerView.State state) |
int |
computeVerticalScrollOffset(RecyclerView.State state) |
int |
computeVerticalScrollRange(RecyclerView.State state) |
RecyclerView.LayoutParams |
generateDefaultLayoutParams() |
int |
getGravity()
Gets the current
Gravity that specifies how the empty space left after items
are laid out is redistributed. |
int |
getLineSpacing()
Gets a value in pixels indicating the space that will be left between each line with items.
|
int |
getMinimumItemSpacing()
Gets the minimum item spacing between items that are laid out on a single line.
|
void |
onAdapterChanged(RecyclerView.Adapter oldAdapter,
RecyclerView.Adapter newAdapter) |
void |
onItemsAdded(RecyclerView recyclerView,
int positionStart,
int itemCount) |
void |
onItemsChanged(RecyclerView recyclerView) |
void |
onItemsMoved(RecyclerView recyclerView,
int from,
int to,
int itemCount) |
void |
onItemsRemoved(RecyclerView recyclerView,
int positionStart,
int itemCount) |
void |
onLayoutChildren(RecyclerView.Recycler recycler,
RecyclerView.State state) |
int |
scrollHorizontallyBy(int dx,
RecyclerView.Recycler recycler,
RecyclerView.State state) |
void |
scrollToPosition(int position) |
int |
scrollVerticallyBy(int dy,
RecyclerView.Recycler recycler,
RecyclerView.State state) |
void |
setGravity(int gravity)
Sets a new
Gravity that will determine how the empty space left after items
are laid out will be redistributed. |
void |
setLineSpacing(int lineSpacing)
Sets a new value in pixels indicating the space that will be left between each line with items.
|
void |
setMinimumItemSpacing(int minimumItemSpacing)
Sets the minimum item spacing between items that are laid out on a single line.
|
addDisappearingView, addDisappearingView, addView, addView, assertInLayoutOrScroll, assertNotInLayoutOrScroll, attachView, attachView, attachView, calculateItemDecorationsForChild, checkLayoutParams, chooseSize, detachAndScrapAttachedViews, detachAndScrapView, detachAndScrapViewAt, detachView, detachViewAt, endAnimation, findContainingItemView, findViewByPosition, generateLayoutParams, generateLayoutParams, getBaseline, getBottomDecorationHeight, getChildAt, getChildCount, getChildMeasureSpec, getChildMeasureSpec, getClipToPadding, getColumnCountForAccessibility, getDecoratedBottom, getDecoratedLeft, getDecoratedMeasuredHeight, getDecoratedMeasuredWidth, getDecoratedRight, getDecoratedTop, getFocusedChild, getHeight, getHeightMode, getItemCount, getItemViewType, getLayoutDirection, getLeftDecorationWidth, getMinimumHeight, getMinimumWidth, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getPosition, getProperties, getRightDecorationWidth, getRowCountForAccessibility, getSelectionModeForAccessibility, getTopDecorationHeight, getWidth, getWidthMode, hasFocus, ignoreView, isAttachedToWindow, isAutoMeasureEnabled, isFocused, isLayoutHierarchical, isMeasurementCacheEnabled, isSmoothScrolling, layoutDecorated, measureChild, measureChildWithMargins, moveView, offsetChildrenHorizontal, offsetChildrenVertical, onAddFocusables, onAttachedToWindow, onDetachedFromWindow, onDetachedFromWindow, onFocusSearchFailed, onInitializeAccessibilityEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onInitializeAccessibilityNodeInfoForItem, onInterceptFocusSearch, onItemsUpdated, onItemsUpdated, onMeasure, onRequestChildFocus, onRequestChildFocus, onRestoreInstanceState, onSaveInstanceState, onScrollStateChanged, performAccessibilityAction, performAccessibilityActionForItem, postOnAnimation, removeAllViews, removeAndRecycleAllViews, removeAndRecycleView, removeAndRecycleViewAt, removeCallbacks, removeDetachedView, removeView, removeViewAt, requestChildRectangleOnScreen, requestLayout, requestSimpleAnimationsInNextLayout, setAutoMeasureEnabled, setMeasuredDimension, setMeasuredDimension, setMeasurementCacheEnabled, smoothScrollToPosition, startSmoothScroll, stopIgnoringView, supportsPredictiveItemAnimations
public static final int HORIZONTAL
public static final int VERTICAL
public WrapLayoutManager(Context context)
WrapLayoutManager
class.context
- the context to be usedpublic WrapLayoutManager(Context context, int orientation)
WrapLayoutManager
class.context
- the context to be usedorientation
- specifies the layout orientation - HORIZONTAL
or VERTICAL
public WrapLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
WrapLayoutManager
class.public int getGravity()
Gravity
that specifies how the empty space left after items
are laid out is redistributed.Gravity
public void setGravity(int gravity)
Gravity
that will determine how the empty space left after items
are laid out will be redistributed.gravity
- the new gravitypublic int getLineSpacing()
public void setLineSpacing(int lineSpacing)
lineSpacing
- the line spacingpublic int getMinimumItemSpacing()
public void setMinimumItemSpacing(int minimumItemSpacing)
minimumItemSpacing
- the minimum item spacingpublic RecyclerView.LayoutParams generateDefaultLayoutParams()
generateDefaultLayoutParams
in class RecyclerView.LayoutManager
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state)
onLayoutChildren
in class RecyclerView.LayoutManager
public int computeHorizontalScrollOffset(RecyclerView.State state)
computeHorizontalScrollOffset
in class RecyclerView.LayoutManager
public int computeVerticalScrollOffset(RecyclerView.State state)
computeVerticalScrollOffset
in class RecyclerView.LayoutManager
public int computeHorizontalScrollExtent(RecyclerView.State state)
computeHorizontalScrollExtent
in class RecyclerView.LayoutManager
public int computeVerticalScrollExtent(RecyclerView.State state)
computeVerticalScrollExtent
in class RecyclerView.LayoutManager
public int computeHorizontalScrollRange(RecyclerView.State state)
computeHorizontalScrollRange
in class RecyclerView.LayoutManager
public int computeVerticalScrollRange(RecyclerView.State state)
computeVerticalScrollRange
in class RecyclerView.LayoutManager
public boolean canScrollHorizontally()
canScrollHorizontally
in class RecyclerView.LayoutManager
public boolean canScrollVertically()
canScrollVertically
in class RecyclerView.LayoutManager
public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State state)
scrollHorizontallyBy
in class RecyclerView.LayoutManager
public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state)
scrollVerticallyBy
in class RecyclerView.LayoutManager
public void scrollToPosition(int position)
scrollToPosition
in class RecyclerView.LayoutManager
public void onItemsAdded(RecyclerView recyclerView, int positionStart, int itemCount)
onItemsAdded
in class RecyclerView.LayoutManager
public void onItemsChanged(RecyclerView recyclerView)
onItemsChanged
in class RecyclerView.LayoutManager
public void onItemsMoved(RecyclerView recyclerView, int from, int to, int itemCount)
onItemsMoved
in class RecyclerView.LayoutManager
public void onItemsRemoved(RecyclerView recyclerView, int positionStart, int itemCount)
onItemsRemoved
in class RecyclerView.LayoutManager
public void onAdapterChanged(RecyclerView.Adapter oldAdapter, RecyclerView.Adapter newAdapter)
onAdapterChanged
in class RecyclerView.LayoutManager