ItemAlignmentFacet


public final class ItemAlignmentFacet


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

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 setItemAlignmentOffset 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' getItemAlignmentFocusViewId. Once a match found, the ItemAlignmentDef is used to calculate alignment position.

Summary

Nested types

Definition of an alignment position under a view.

Constants

static final float

Value indicates that percent is not used.

Public constructors

Public methods

@NonNull ItemAlignmentFacet.ItemAlignmentDef[]

Returns read only definitions of alignment positions.

boolean
void
setAlignmentDefs(@NonNull ItemAlignmentFacet.ItemAlignmentDef[] defs)

Sets definitions of alignment positions.

Constants

ITEM_ALIGN_OFFSET_PERCENT_DISABLED

Added in 1.0.0-alpha03
public static final float ITEM_ALIGN_OFFSET_PERCENT_DISABLED = -1.0f

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

Public constructors

ItemAlignmentFacet

Added in 1.0.0-alpha03
public ItemAlignmentFacet()

Public methods

getAlignmentDefs

Added in 1.0.0-alpha03
public @NonNull ItemAlignmentFacet.ItemAlignmentDef[] getAlignmentDefs()

Returns read only definitions of alignment positions.

isMultiAlignment

Added in 1.0.0-alpha03
public boolean isMultiAlignment()

setAlignmentDefs

Added in 1.0.0-alpha03
public void setAlignmentDefs(@NonNull ItemAlignmentFacet.ItemAlignmentDef[] defs)

Sets definitions of alignment positions.