RecyclerView.LayoutParams

class RecyclerView.LayoutParams : ViewGroup.MarginLayoutParams

Known direct subclasses
GridLayoutManager.LayoutParams

LayoutParams used by GridLayoutManager.

StaggeredGridLayoutManager.LayoutParams

LayoutParams used by StaggeredGridLayoutManager.


LayoutParams subclass for children of RecyclerView. Custom layout managers are encouraged to create their own subclass of this LayoutParams class to store any additional required per-child view metadata about the layout.

Summary

Public functions

Int

Returns the up-to-date adapter position that the view this LayoutParams is attached to corresponds to in the RecyclerView.

Int

Returns the up-to-date adapter position that the view this LayoutParams is attached to corresponds to with respect to the Adapter that bound this View.

Int

This function is deprecated.

This method is confusing when nested adapters are used.

Int

Returns the adapter position that the view this LayoutParams is attached to corresponds to as of latest layout calculation.

Int

This function is deprecated.

use getViewLayoutPosition or getViewAdapterPosition

Boolean

Returns true if the adapter data item corresponding to the view this LayoutParams is attached to has been changed in the data set.

Boolean

Returns true if the adapter data item corresponding to the view this LayoutParams is attached to has been removed from the data set.

Boolean

Returns true if the view this LayoutParams is attached to is now representing potentially invalid data.

Boolean

Returns true if the view this LayoutParams is attached to needs to have its content updated from the corresponding adapter.

Inherited Constants

From android.view.ViewGroup.LayoutParams
const Int

This property is deprecated.

const Int
const Int

Public constructors

LayoutParams

Added in 1.0.0
LayoutParams(source: RecyclerView.LayoutParams!)

LayoutParams

Added in 1.0.0
LayoutParams(source: ViewGroup.LayoutParams!)

LayoutParams

Added in 1.0.0
LayoutParams(source: ViewGroup.MarginLayoutParams!)

LayoutParams

Added in 1.0.0
LayoutParams(c: Context!, attrs: AttributeSet!)

LayoutParams

Added in 1.0.0
LayoutParams(width: Int, height: Int)

Public functions

getAbsoluteAdapterPosition

Added in 1.2.0
fun getAbsoluteAdapterPosition(): Int

Returns the up-to-date adapter position that the view this LayoutParams is attached to corresponds to in the RecyclerView. If the RecyclerView has an Adapter that merges other adapters, this position will be with respect to the adapter that is assigned to the RecyclerView.

Returns
Int

the up-to-date adapter position this view with respect to the RecyclerView. It may return NO_POSITION if item represented by this View has been removed or its up-to-date position cannot be calculated.

getBindingAdapterPosition

Added in 1.2.0
fun getBindingAdapterPosition(): Int

Returns the up-to-date adapter position that the view this LayoutParams is attached to corresponds to with respect to the Adapter that bound this View.

Returns
Int

the up-to-date adapter position this view relative to the Adapter that bound this View. It may return NO_POSITION if item represented by this View has been removed or its up-to-date position cannot be calculated.

getViewAdapterPosition

Added in 1.0.0
Deprecated in 1.2.0
fun getViewAdapterPosition(): Int

getViewLayoutPosition

Added in 1.0.0
fun getViewLayoutPosition(): Int

Returns the adapter position that the view this LayoutParams is attached to corresponds to as of latest layout calculation.

Returns
Int

the adapter position this view as of latest layout pass

getViewPosition

Added in 1.0.0
Deprecated in 1.0.0
fun getViewPosition(): Int

isItemChanged

Added in 1.0.0
fun isItemChanged(): Boolean

Returns true if the adapter data item corresponding to the view this LayoutParams is attached to has been changed in the data set. A LayoutManager may choose to treat it differently in order to animate its changing state.

Returns
Boolean

true if the item the view corresponds to was changed in the data set

isItemRemoved

Added in 1.0.0
fun isItemRemoved(): Boolean

Returns true if the adapter data item corresponding to the view this LayoutParams is attached to has been removed from the data set. A LayoutManager may choose to treat it differently in order to animate its outgoing or disappearing state.

Returns
Boolean

true if the item the view corresponds to was removed from the data set

isViewInvalid

Added in 1.0.0
fun isViewInvalid(): Boolean

Returns true if the view this LayoutParams is attached to is now representing potentially invalid data. A LayoutManager should scrap/recycle it.

Returns
Boolean

true if the view is invalid

viewNeedsUpdate

Added in 1.0.0
fun viewNeedsUpdate(): Boolean

Returns true if the view this LayoutParams is attached to needs to have its content updated from the corresponding adapter.

Returns
Boolean

true if the view should have its content updated