OrientationHelper
abstract class OrientationHelper
kotlin.Any | |
↳ | androidx.recyclerview.widget.OrientationHelper |
Helper class for LayoutManagers to abstract measurements depending on the View's orientation.
It is developed to easily support vertical and horizontal orientations in a LayoutManager but can also be used to abstract calls around view bounds and child measurements with margins and decorations.
Summary
Constants | |
---|---|
static Int | |
static Int |
Public methods | |
---|---|
open static OrientationHelper! |
createHorizontalHelper(layoutManager: RecyclerView.LayoutManager!) Creates a horizontal OrientationHelper for the given LayoutManager. |
open static OrientationHelper! |
createOrientationHelper(layoutManager: RecyclerView.LayoutManager!, orientation: Int) Creates an OrientationHelper for the given LayoutManager and orientation. |
open static OrientationHelper! |
createVerticalHelper(layoutManager: RecyclerView.LayoutManager!) Creates a vertical OrientationHelper for the given LayoutManager. |
abstract Int |
getDecoratedEnd(view: View!) Returns the end of the view including its decoration and margin. |
abstract Int |
getDecoratedMeasurement(view: View!) Returns the space occupied by this View in the current orientation including decorations and margins. |
abstract Int |
getDecoratedMeasurementInOther(view: View!) Returns the space occupied by this View in the perpendicular orientation including decorations and margins. |
abstract Int |
getDecoratedStart(view: View!) Returns the start of the view including its decoration and margin. |
abstract Int |
getEnd() Returns the end position of the layout without taking padding into account. |
abstract Int |
Returns the end position of the layout after the end padding is removed. |
abstract Int |
Returns the padding at the end of the layout. |
open RecyclerView.LayoutManager! |
Returns the |
abstract Int |
getMode() Returns the MeasureSpec mode for the current orientation from the LayoutManager. |
abstract Int |
Returns the MeasureSpec mode for the perpendicular orientation from the LayoutManager. |
abstract Int |
Returns the start position of the layout after the start padding is added. |
abstract Int |
Returns the total space to layout. |
open Int |
Returns the layout space change between the previous layout pass and current layout pass. |
abstract Int |
getTransformedEndWithDecoration(view: View!) Returns the end of the View after its matrix transformations are applied to its layout position. |
abstract Int |
Returns the start of the View after its matrix transformations are applied to its layout position. |
abstract Unit |
offsetChild(view: View!, offset: Int) Offsets the child in this orientation. |
abstract Unit |
offsetChildren(amount: Int) Offsets all children's positions by the given amount. |
open Unit |
Call this method after onLayout method is complete if state is NOT pre-layout. |
Properties | |
---|---|
RecyclerView.LayoutManager! |
Constants
Public methods
createHorizontalHelper
open static fun createHorizontalHelper(layoutManager: RecyclerView.LayoutManager!): OrientationHelper!
Creates a horizontal OrientationHelper for the given LayoutManager.
Parameters | |
---|---|
layoutManager |
RecyclerView.LayoutManager!: The LayoutManager to attach to. |
Return | |
---|---|
OrientationHelper! |
A new OrientationHelper |
createOrientationHelper
open static fun createOrientationHelper(
layoutManager: RecyclerView.LayoutManager!,
orientation: Int
): OrientationHelper!
Creates an OrientationHelper for the given LayoutManager and orientation.
Parameters | |
---|---|
layoutManager |
RecyclerView.LayoutManager!: LayoutManager to attach to |
orientation |
Int: Desired orientation. Should be HORIZONTAL or VERTICAL |
Return | |
---|---|
OrientationHelper! |
A new OrientationHelper |
createVerticalHelper
open static fun createVerticalHelper(layoutManager: RecyclerView.LayoutManager!): OrientationHelper!
Creates a vertical OrientationHelper for the given LayoutManager.
Parameters | |
---|---|
layoutManager |
RecyclerView.LayoutManager!: The LayoutManager to attach to. |
Return | |
---|---|
OrientationHelper! |
A new OrientationHelper |
getDecoratedEnd
abstract fun getDecoratedEnd(view: View!): Int
Returns the end of the view including its decoration and margin.
For example, for the horizontal helper, if a View's right is at pixel 200, has 2px right decoration and 3px right margin, returned value will be 205.
Parameters | |
---|---|
view |
View!: The view element to check |
Return | |
---|---|
Int |
The last pixel of the element |
getDecoratedMeasurement
abstract fun getDecoratedMeasurement(view: View!): Int
Returns the space occupied by this View in the current orientation including decorations and margins.
Parameters | |
---|---|
view |
View!: The view element to check |
Return | |
---|---|
Int |
Total space occupied by this view |
getDecoratedMeasurementInOther
abstract fun getDecoratedMeasurementInOther(view: View!): Int
Returns the space occupied by this View in the perpendicular orientation including decorations and margins.
Parameters | |
---|---|
view |
View!: The view element to check |
Return | |
---|---|
Int |
Total space occupied by this view in the perpendicular orientation to current one |
See Also
getDecoratedStart
abstract fun getDecoratedStart(view: View!): Int
Returns the start of the view including its decoration and margin.
For example, for the horizontal helper, if a View's left is at pixel 20, has 2px left decoration and 3px left margin, returned value will be 15px.
Parameters | |
---|---|
view |
View!: The view element to check |
Return | |
---|---|
Int |
The first pixel of the element |
See Also
getEnd
abstract fun getEnd(): Int
Returns the end position of the layout without taking padding into account.
Return | |
---|---|
Int |
The end boundary for this layout without considering padding. |
getEndAfterPadding
abstract fun getEndAfterPadding(): Int
Returns the end position of the layout after the end padding is removed.
Return | |
---|---|
Int |
The end boundary for this layout. |
getEndPadding
abstract fun getEndPadding(): Int
Returns the padding at the end of the layout. For horizontal helper, this is the right padding and for vertical helper, this is the bottom padding. This method does not check whether the layout is RTL or not.
Return | |
---|---|
Int |
The padding at the end of the layout. |
getLayoutManager
open fun getLayoutManager(): RecyclerView.LayoutManager!
Returns the LayoutManager
that is associated with this OrientationHelper.
getMode
abstract fun getMode(): Int
Returns the MeasureSpec mode for the current orientation from the LayoutManager.
Return | |
---|---|
Int |
The current measure spec mode. |