Known direct subclasses
A flexible view for providing a limited window into a large data set.
Glossary of terms:
- Adapter: A subclass of
RecyclerView.Adapterresponsible for providing views that represent items in a data set.
- Position: The position of a data item within an Adapter.
- Index: The index of an attached child view as used in a call to
ViewGroup.getChildAt(int). Contrast with Position.
- Binding: The process of preparing a child view to display data corresponding to a position within the adapter.
- Recycle (view): A view previously used to display data for a specific adapter position may be placed in a cache for later reuse to display the same type of data again later. This can drastically improve performance by skipping initial layout inflation or construction.
- Scrap (view): A child view that has entered into a temporarily detached state during layout. Scrap views may be reused without becoming fully detached from the parent RecyclerView, either unmodified if no rebinding is required or modified by the adapter if the view was considered dirty.
- Dirty (view): A child view that must be rebound by the adapter before being displayed.
Positions in RecyclerView:
RecyclerView introduces an additional level of abstraction between the
RecyclerView.LayoutManager to be able to detect data set changes in batches during a layout
calculation. This saves LayoutManager from tracking adapter changes to calculate animations.
It also helps with performance because all view bindings happen at the same time and unnecessary
bindings are avoided.
For this reason, there are two types of
position related methods in RecyclerView:
- layout position: Position of an item in the latest layout calculation. This is the position from the LayoutManager's perspective.
- adapter position: Position of an item in the adapter. This is the position from the Adapter's perspective.
These two positions are the same except the time between dispatching
events and calculating the updated layout.
Methods that return or receive
*LayoutPosition* use position as of the latest
layout calculation (e.g.