ItemAlignmentDef

class ItemAlignmentDef
kotlin.Any
   ↳ androidx.leanback.widget.ItemAlignmentFacet.ItemAlignmentDef

Definition of an alignment position under a view.

Summary

Public constructors

Public methods
Boolean

Returns true if applies padding to item alignment when #getItemAlignmentOffsetPercent() is 0 or 100; returns false otherwise.

Unit

When true, align to View#getBaseline() for the view of with id equals #getItemAlignmentViewId(); false otherwise.

open Boolean

Returns true when View should be aligned to View#getBaseline()

Int

Returns number of pixels to the end of low edge.

Int

Returns Id of which child view take focus for alignment.

Unit

Sets Id of which child view take focus for alignment.

Int

Returns Id of which child view to be aligned.

Unit

Sets the offset percent for item alignment in addition to offset.

Unit

Sets number of pixels to the end of low edge.

Unit

Sets whether applies padding to item alignment when #getItemAlignmentOffsetPercent() is 0 or 100.

Unit

Sets Id of which child view to be aligned.

Float

Gets the offset percent for item alignment in addition to offset.

Public constructors

<init>

ItemAlignmentDef()

Public methods

isItemAlignmentOffsetWithPadding

fun isItemAlignmentOffsetWithPadding(): Boolean

Returns true if applies padding to item alignment when #getItemAlignmentOffsetPercent() is 0 or 100; returns false otherwise.

When true: Applies start/top padding when #getItemAlignmentOffsetPercent() is 0. Applies end/bottom padding when #getItemAlignmentOffsetPercent() is 100. Does not apply padding if #getItemAlignmentOffsetPercent() is neither 0 nor 100.

When false: does not apply padding

setAlignedToTextViewBaseline

fun setAlignedToTextViewBaseline(alignToBaseline: Boolean): Unit

When true, align to View#getBaseline() for the view of with id equals #getItemAlignmentViewId(); false otherwise.

Parameters
alignToBaseline Boolean: Boolean indicating whether to align to view baseline.

isAlignedToTextViewBaseLine

open fun isAlignedToTextViewBaseLine(): Boolean

Returns true when View should be aligned to View#getBaseline()

getItemAlignmentOffset

fun getItemAlignmentOffset(): Int

Returns number of pixels to the end of low edge. Supports right to left layout direction. In left to right or vertical case, it's the offset added to left/top edge. In right to left case, it's the offset subtracted from right edge.

Return
Int: Number of pixels to the end of low edge.

getItemAlignmentFocusViewId

fun getItemAlignmentFocusViewId(): Int

Returns Id of which child view take focus for alignment. When not set, it will use use same id of #getItemAlignmentViewId()

setItemAlignmentFocusViewId

fun setItemAlignmentFocusViewId(viewId: Int): Unit

Sets Id of which child view take focus for alignment. When not set, it will use use same id of #getItemAlignmentViewId().

Parameters
viewId Int: The id of child view that will be focused to.

getItemAlignmentViewId

fun getItemAlignmentViewId(): Int

Returns Id of which child view to be aligned. View.NO_ID refers to root view and should be only used in first one. Different view ids of #getAlignmentDefs() define multiple alignment steps within one itemView, e.g. there are two child views R.id.child1 and R.id.child2. App may allocated two ItemAlignmentDefs, one with view id R.id.child1, the other with view id R.id.child2. Note this id may or may not be same as the child view that takes focus.

setItemAlignmentOffsetPercent

fun setItemAlignmentOffsetPercent(percent: Float): Unit

Sets the offset percent for item alignment in addition to offset. E.g., 40 means 40% of width/height from the low edge. In the right to left case, it's the 40% width from right edge. Use #ITEM_ALIGN_OFFSET_PERCENT_DISABLED to disable.

setItemAlignmentOffset

fun setItemAlignmentOffset(offset: Int): Unit

Sets number of pixels to the end of low edge. Supports right to left layout direction.

Parameters
offset Int: In left to right or vertical case, it's the offset added to left/top edge. In right to left case, it's the offset subtracted from right edge.

setItemAlignmentOffsetWithPadding

fun setItemAlignmentOffsetWithPadding(withPadding: Boolean): Unit

Sets whether applies padding to item alignment when #getItemAlignmentOffsetPercent() is 0 or 100.

When true: Applies start/top padding if #getItemAlignmentOffsetPercent() is 0. Applies end/bottom padding if #getItemAlignmentOffsetPercent() is 100. Does not apply padding if #getItemAlignmentOffsetPercent() is neither 0 nor 100.

When false: does not apply padding

setItemAlignmentViewId

fun setItemAlignmentViewId(viewId: Int): Unit

Sets Id of which child view to be aligned. View.NO_ID refers to root view and should be only used in first one. Different view ids of #getAlignmentDefs() define multiple alignment steps within one itemView, e.g. there are two child views R.id.child1 and R.id.child2. App may allocated two ItemAlignmentDefs, one with view id R.id.child1, the other with view id R.id.child2. Note this id may or may not be same as the child view that takes focus.

Parameters
viewId Int: The id of child view that will be aligned to.

getItemAlignmentOffsetPercent

fun getItemAlignmentOffsetPercent(): Float

Gets the offset percent for item alignment in addition to offset. E.g., 40 means 40% of the width from the low edge. In the right to left case, it's the 40% from right edge. Use #ITEM_ALIGN_OFFSET_PERCENT_DISABLED to disable.