LayoutManager
abstract class LayoutManager
kotlin.Any | |
↳ | androidx.recyclerview.widget.RecyclerView.LayoutManager |
A LayoutManager
is responsible for measuring and positioning item views within a RecyclerView
as well as determining the policy for when to recycle item views that are no longer visible to the user. By changing the LayoutManager
a RecyclerView
can be used to implement a standard vertically scrolling list, a uniform grid, staggered grids, horizontally scrolling collections and more. Several stock layout managers are provided for general use.
Context
, AttributeSet
, int
, int
), RecyclerView will instantiate and set the LayoutManager when being inflated. Most used properties can be then obtained from getProperties(Context, AttributeSet, int, int)
. In case a LayoutManager specifies both constructors, the non-default constructor will take precedence.
Summary
Nested classes | |
---|---|
abstract |
Interface for LayoutManagers to request items to be prefetched, based on position, with specified distance from viewport, which indicates priority. |
open |
Some general properties that a LayoutManager may want to use. |
Public constructors | |
---|---|
<init>() A |
Public methods | |
---|---|
open Unit |
addDisappearingView(child: View!) To be called only during |
open Unit |
addDisappearingView(child: View!, index: Int) To be called only during |
open Unit |
Add a view to the currently attached RecyclerView if needed. |
open Unit |
Add a view to the currently attached RecyclerView if needed. |
open Unit |
assertInLayoutOrScroll(message: String!) Checks if RecyclerView is in the middle of a layout or scroll and throws an |
open Unit |
assertNotInLayoutOrScroll(message: String!) Checks if RecyclerView is in the middle of a layout or scroll and throws an |
open Unit |
attachView(@NonNull child: View, index: Int, lp: RecyclerView.LayoutParams!) Reattach a previously |
open Unit |
attachView(@NonNull child: View, index: Int) Reattach a previously |
open Unit |
attachView(@NonNull child: View) Reattach a previously |
open Unit |
calculateItemDecorationsForChild(@NonNull child: View, @NonNull outRect: Rect) Calculates the item decor insets applied to the given child and updates the provided Rect instance with the inset values. |
open Boolean |
Query if horizontal scrolling is currently supported. |
open Boolean |
Query if vertical scrolling is currently supported. |
open Boolean |
Determines the validity of the supplied LayoutParams object. |
open static Int |
chooseSize(spec: Int, desired: Int, min: Int) Chooses a size from the given specs and parameters that is closest to the desired size and also complies with the spec. |
open Unit |
collectAdjacentPrefetchPositions(dx: Int, dy: Int, state: RecyclerView.State!, layoutPrefetchRegistry: RecyclerView.LayoutManager.LayoutPrefetchRegistry!) Gather all positions from the LayoutManager to be prefetched, given specified momentum. |
open Unit |
collectInitialPrefetchPositions(adapterItemCount: Int, layoutPrefetchRegistry: RecyclerView.LayoutManager.LayoutPrefetchRegistry!) Gather all positions from the LayoutManager to be prefetched in preperation for its RecyclerView to come on screen, due to the movement of another, containing RecyclerView. |
open Int |
computeHorizontalScrollExtent(@NonNull state: RecyclerView.State) Override this method if you want to support scroll bars. |
open Int |
computeHorizontalScrollOffset(@NonNull state: RecyclerView.State) Override this method if you want to support scroll bars. |
open Int |
computeHorizontalScrollRange(@NonNull state: RecyclerView.State) Override this method if you want to support scroll bars. |
open Int |
computeVerticalScrollExtent(@NonNull state: RecyclerView.State) Override this method if you want to support scroll bars. |
open Int |
computeVerticalScrollOffset(@NonNull state: RecyclerView.State) Override this method if you want to support scroll bars. |
open Int |
computeVerticalScrollRange(@NonNull state: RecyclerView.State) Override this method if you want to support scroll bars. |
open Unit |
detachAndScrapAttachedViews(@NonNull recycler: RecyclerView.Recycler) Temporarily detach and scrap all currently attached child views. |
open Unit |
detachAndScrapView(@NonNull child: View, @NonNull recycler: RecyclerView.Recycler) Detach a child view and add it to a |
open Unit |
detachAndScrapViewAt(index: Int, @NonNull recycler: RecyclerView.Recycler) Detach a child view and add it to a |
open Unit |
detachView(@NonNull child: View) Temporarily detach a child view. |
open Unit |
detachViewAt(index: Int) Temporarily detach a child view. |
open Unit |
endAnimation(view: View!) Ends all animations on the view created by the |
open View? |
findContainingItemView(@NonNull view: View) Traverses the ancestors of the given view and returns the item view that contains it and also a direct child of the LayoutManager. |
open View? |
findViewByPosition(position: Int) Finds the view which represents the given adapter position. |
abstract RecyclerView.LayoutParams! |
Create a default |
open RecyclerView.LayoutParams! |
Create a LayoutParams object suitable for this LayoutManager, copying relevant values from the supplied LayoutParams object if possible. |
open RecyclerView.LayoutParams! |
generateLayoutParams(c: Context!, attrs: AttributeSet!) |