Google 致力于为黑人社区推动种族平等。查看具体举措

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.

If the LayoutManager specifies a default constructor or one with the signature (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

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.

Public methods
open Unit

To be called only during onLayoutChildren(Recycler, State) to add a view to the layout that is known to be going away, either because it has been removed or because it is actually not in the visible portion of the container but is being laid out in order to inform RecyclerView in how to animate the item out of view.

open Unit
addDisappearingView(child: View!, index: Int)

To be called only during onLayoutChildren(Recycler, State) to add a view to the layout that is known to be going away, either because it has been removed or because it is actually not in the visible portion of the container but is being laid out in order to inform RecyclerView in how to animate the item out of view.

open Unit
addView(child: View!)

Add a view to the currently attached RecyclerView if needed.

open Unit
addView(child: View!, index: Int)

Add a view to the currently attached RecyclerView if needed.

open Unit

Checks if RecyclerView is in the middle of a layout or scroll and throws an IllegalStateException if it is not.

open Unit

Checks if RecyclerView is in the middle of a layout or scroll and throws an IllegalStateException if it is.

open Unit
attachView(@NonNull child: View, index: Int, lp: RecyclerView.LayoutParams!)

Reattach a previously detached view.

open Unit
attachView(@NonNull child: View, index: Int)

Reattach a previously detached view.

open Unit
attachView(@NonNull child: View)

Reattach a previously detached view.

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: