PrimaryLayout
public class PrimaryLayout implements LayoutElementBuilders.LayoutElement
Tiles layout that represents a suggested layout style for Material Tiles with the primary (compact) chip at the bottom with the given content in the center and the recommended margin and padding applied. There is a fixed slot for an optional primary label above or optional secondary label below the main content area.
It is highly recommended that main content has max lines between 2 and 4 (dependant on labels present), i.e.: * No labels are present: content with max 4 lines, * 1 label is present: content with max 3 lines, * 2 labels are present: content with max 2 lines.
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.:
PrimaryLayout pl = new PrimaryLayout... Box box = new Box.Builder().addContent(pl).build(); PrimaryLayout myPl = (PrimaryLayout) box.getContents().get(0);
To be able to get PrimaryLayout object from any layout element, fromLayoutElement method should be used, i.e.:
PrimaryLayout myPl = PrimaryLayout.fromLayoutElement(box.getContents().get(0));
Summary
Nested types |
|---|
public final class PrimaryLayout.Builder implements LayoutElementBuilders.LayoutElement.BuilderBuilder class for |
Public methods |
|
|---|---|
static @Nullable PrimaryLayout |
Returns PrimaryLayout object from the given androidx.wear.tiles.LayoutElementBuilders.LayoutElement (e.g. one retrieved from a container's content with |
@Nullable LayoutElementBuilders.LayoutElement |
Get the inner content from this layout. |
@Nullable LayoutElementBuilders.LayoutElement |
Get the primary chip content from this layout. |
@Nullable LayoutElementBuilders.LayoutElement |
Get the primary label content from this layout. |
@Nullable LayoutElementBuilders.LayoutElement |
Get the secondary label content from this layout. |
@Dimension(unit = 0) float |
Get the vertical spacer height from this layout. |
Public methods
public static @Nullable PrimaryLayoutfromLayoutElement(@NonNull LayoutElementBuilders.LayoutElement element)
Returns PrimaryLayout 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 PrimaryLayout. Otherwise, it will return null.
public @Nullable LayoutElementBuilders.LayoutElementgetContent()
Get the inner content from this layout.
public @Nullable LayoutElementBuilders.LayoutElementgetPrimaryChipContent()
Get the primary chip content from this layout.
public @Nullable LayoutElementBuilders.LayoutElementgetPrimaryLabelTextContent()
Get the primary label content from this layout.
public @Nullable LayoutElementBuilders.LayoutElementgetSecondaryLabelTextContent()
Get the secondary label content from this layout.
public @Dimension(unit = 0) floatgetVerticalSpacerHeight()
Get the vertical spacer height from this layout.