added in version 24.1.0
belongs to Maven artifact com.android.support:leanback-v17:28.0.0-alpha1

ItemAlignmentFacet

public final class ItemAlignmentFacet
extends Object

java.lang.Object
   ↳ android.support.v17.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 setFacet(Class, Object) or setFacet(Class, Object). Facet on ViewHolder has a higher priority than Presenter or Adapter.

ItemAlignmentFacet contains single or multiple ItemAlignmentFacet.ItemAlignmentDefs. First ItemAlignmentFacet.ItemAlignmentDef describes the default alignment position for ViewHolder, it also overrides the default item alignment settings on VerticalGridView and HorizontalGridView (see setItemAlignmentOffset(int) etc). One ItemAlignmentFacet can have multiple ItemAlignmentFacet.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 ItemAlignmentFacet.ItemAlignmentDefs' getItemAlignmentFocusViewId(). Once a match found, the ItemAlignmentFacet.ItemAlignmentDef is used to calculate alignment position.

Summary

Nested classes

class ItemAlignmentFacet.ItemAlignmentDef

Definition of an alignment position under a view. 

Constants

float ITEM_ALIGN_OFFSET_PERCENT_DISABLED

Value indicates that percent is not used.

Public constructors

ItemAlignmentFacet()

Public methods

ItemAlignmentDef[] getAlignmentDefs()

Returns read only definitions of alignment positions.

boolean isMultiAlignment()
void setAlignmentDefs(ItemAlignmentDef[] defs)

Sets definitions of alignment positions.

Inherited methods

From class java.lang.Object

Constants

ITEM_ALIGN_OFFSET_PERCENT_DISABLED

added in version 24.1.0
float ITEM_ALIGN_OFFSET_PERCENT_DISABLED

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

Constant Value: -1.0

Public constructors

ItemAlignmentFacet

added in version 24.1.0
ItemAlignmentFacet ()

Public methods

getAlignmentDefs

added in version 24.1.0
ItemAlignmentDef[] getAlignmentDefs ()

Returns read only definitions of alignment positions.

Returns
ItemAlignmentDef[]

isMultiAlignment

added in version 24.1.0
boolean isMultiAlignment ()

Returns
boolean

setAlignmentDefs

added in version 24.1.0
void setAlignmentDefs (ItemAlignmentDef[] defs)

Sets definitions of alignment positions.

Parameters
defs ItemAlignmentDef