MultiButtonLayout
public class MultiButtonLayout implements LayoutElementBuilders.LayoutElement
Opinionated Tiles layout, that can contain between 1 and MULTI_BUTTON_MAX_NUMBER number of buttons arranged inline with the Material guidelines. Can be used as a content passed in to the PrimaryLayout, but if there is MULTI_BUTTON_MAX_NUMBER buttons it should be used on its own.
For additional examples and suggested layouts see Tiles Design System.
When accessing the contents of a container for testing, note that this element can't be simply casted back to the original type, i.e.:
MultiButtonLayout mbl = new MultiButtonLayout... Box box = new Box.Builder().addContent(mbl).build(); MultiButtonLayout myMbl = (MultiButtonLayout) box.getContents().get(0);
To be able to get MultiButtonLayout object from any layout element, fromLayoutElement method should be used, i.e.:
MultiButtonLayout myMbl = MultiButtonLayout.fromLayoutElement(box.getContents().get(0));
Summary
Nested types |
|---|
public final class MultiButtonLayout.Builder implements LayoutElementBuilders.LayoutElement.BuilderBuilder class for |
Constants |
|
|---|---|
static final int |
Button distribution where the last row has more buttons than other rows. |
static final int |
Button distribution where the first row has more buttons than other rows. |
Public methods |
|
|---|---|
static @Nullable MultiButtonLayout |
Returns MultiButtonLayout object from the given androidx.wear.tiles.LayoutElementBuilders.LayoutElement (e.g. one retrieved from a container's content with |
@NonNull List<LayoutElementBuilders.LayoutElement> |
Gets the content from this layout, containing all buttons that were added. |
int |
Gets the button distribution from this layout for the case when there is 5 buttons in the layout. |
Constants
public static final int FIVE_BUTTON_DISTRIBUTION_BOTTOM_HEAVY = 2
Button distribution where the last row has more buttons than other rows.
public static final int FIVE_BUTTON_DISTRIBUTION_TOP_HEAVY = 1
Button distribution where the first row has more buttons than other rows.
Public methods
public static @Nullable MultiButtonLayoutfromLayoutElement(@NonNull LayoutElementBuilders.LayoutElement element)
Returns MultiButtonLayout object from the given androidx.wear.tiles.LayoutElementBuilders.LayoutElement (e.g. one retrieved from a container's content with container.getContents().get(index)) if that element can be converted to MultiButtonLayout. Otherwise, it will return null.
public @NonNull List<LayoutElementBuilders.LayoutElement>getButtonContents()
Gets the content from this layout, containing all buttons that were added.
public int getFiveButtonDistribution()Gets the button distribution from this layout for the case when there is 5 buttons in the layout. If there is more or less buttons than 5, default FIVE_BUTTON_DISTRIBUTION_BOTTOM_HEAVY will be returned.