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 |
|---|
public class ItemAlignmentFacet.ItemAlignmentDefDefinition 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
public static final float ITEM_ALIGN_OFFSET_PERCENT_DISABLED = -1.0f
Value indicates that percent is not used. Equivalent to 0.
Public constructors
Public methods
getAlignmentDefs
public @NonNull ItemAlignmentFacet.ItemAlignmentDef[] getAlignmentDefs()
Returns read only definitions of alignment positions.
setAlignmentDefs
public void setAlignmentDefs(@NonNull ItemAlignmentFacet.ItemAlignmentDef[] defs)
Sets definitions of alignment positions.