ItemAlignmentFacet
public
final
class
ItemAlignmentFacet
extends Object
java.lang.Object | |
↳ | 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 ItemAlignmentFacet.ItemAlignmentDef
s. First
ItemAlignmentFacet.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 ItemAlignmentFacet.ItemAlignmentDef
s, 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.ItemAlignmentDef
s'
ItemAlignmentFacet.ItemAlignmentDef.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 | |
---|---|
Constants
ITEM_ALIGN_OFFSET_PERCENT_DISABLED
public static final float ITEM_ALIGN_OFFSET_PERCENT_DISABLED
Value indicates that percent is not used. Equivalent to 0.
Constant Value: -1.0
Public constructors
ItemAlignmentFacet
public ItemAlignmentFacet ()
Public methods
getAlignmentDefs
public ItemAlignmentDef[] getAlignmentDefs ()
Returns read only definitions of alignment positions.
Returns | |
---|---|
ItemAlignmentDef[] |
isMultiAlignment
public boolean isMultiAlignment ()
Returns | |
---|---|
boolean |
setAlignmentDefs
public void setAlignmentDefs (ItemAlignmentDef[] defs)
Sets definitions of alignment positions.
Parameters | |
---|---|
defs |
ItemAlignmentDef |
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-02-24 UTC.