The Android Developer Challenge is back! Submit your idea before December 2.

ItemAlignmentFacet

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

Optional facet provided by RecyclerView.Adapter or RecyclerView.ViewHolder for use in HorizontalGridView and VerticalGridView. Apps using Presenter may set facet using Presenter#setFacet(Class, Object) or Presenter.ViewHolder#setFacet(Class, Object). Facet on ViewHolder has a higher priority than Presenter or Adapter.

ItemAlignmentFacet contains single or multiple ItemAlignmentDefs. First ItemAlignmentDef describes the default alignment position for ViewHolder, it also overrides the default item alignment settings on VerticalGridView and HorizontalGridView (see BaseGridView#setItemAlignmentOffset(int) etc). One ItemAlignmentFacet can have multiple ItemAlignmentDefs, e.g. having two aligned positions when child1 gets focus or child2 gets focus. Grid view will visit focused view and its ancestors till the root of ViewHolder to match ItemAlignmentDefs' ItemAlignmentDef#getItemAlignmentFocusViewId(). Once a match found, the ItemAlignmentDef is used to calculate alignment position.

Summary

Nested classes

Definition of an alignment position under a view.

Constants

static Float

Value indicates that percent is not used.

Public constructors

Optional facet provided by RecyclerView.Adapter or RecyclerView.ViewHolder for use in HorizontalGridView and VerticalGridView.

Public methods

Array<ItemAlignmentFacet.ItemAlignmentDef!>!

Returns read only definitions of alignment positions.

Boolean

Unit

Sets definitions of alignment positions.

Constants

ITEM_ALIGN_OFFSET_PERCENT_DISABLED

static val ITEM_ALIGN_OFFSET_PERCENT_DISABLED: Float

Value indicates that percent is not used. Equivalent to 0.

Value: -1

Public constructors

<init>

ItemAlignmentFacet()

Optional facet provided by RecyclerView.Adapter or RecyclerView.ViewHolder for use in HorizontalGridView and VerticalGridView. Apps using Presenter may set facet using Presenter#setFacet(Class, Object) or Presenter.ViewHolder#setFacet(Class, Object). Facet on ViewHolder has a higher priority than Presenter or Adapter.

ItemAlignmentFacet contains single or multiple ItemAlignmentDefs. First ItemAlignmentDef describes the default alignment position for ViewHolder, it also overrides the default item alignment settings on VerticalGridView and HorizontalGridView (see BaseGridView#setItemAlignmentOffset(int) etc). One ItemAlignmentFacet can have multiple ItemAlignmentDefs, e.g. having two aligned positions when child1 gets focus or child2 gets focus. Grid view will visit focused view and its ancestors till the root of ViewHolder to match ItemAlignmentDefs' ItemAlignmentDef#getItemAlignmentFocusViewId(). Once a match found, the ItemAlignmentDef is used to calculate alignment position.

Public methods

getAlignmentDefs

fun getAlignmentDefs(): Array<ItemAlignmentFacet.ItemAlignmentDef!>!

Returns read only definitions of alignment positions.

isMultiAlignment

fun isMultiAlignment(): Boolean

setAlignmentDefs

fun setAlignmentDefs(defs: Array<ItemAlignmentFacet.ItemAlignmentDef!>!): Unit

Sets definitions of alignment positions.