public class TitleChip implements LayoutElementBuilders.LayoutElement


ProtoLayout component TitleChip that represents clickable object with the text.

The Title Chip is Stadium shaped object with a larger height then standard Chip and it will take one line of text of TYPOGRAPHY_TITLE2 style.

The recommended set of ChipColors styles can be obtained from ChipDefaults, e.g. TITLE_PRIMARY_COLORS to get a color scheme for a primary .

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.:

TitleChip chip = new TitleChip...
Box box = new Box.Builder().addContent(chip).build();

TitleChip myChip = (TitleChip) box.getContents().get(0);
will fail.

To be able to get TitleChip object from any layout element, fromLayoutElement method should be used, i.e.:

TitleChip myChip = TitleChip.fromLayoutElement(box.getContents().get(0));
See also
setContent

if this TitleChip is used inside of androidx.wear.protolayout.material.layouts.PrimaryLayout.

Summary

Nested types

public final class TitleChip.Builder

Builder class for TitleChip.

Public methods

static @Nullable TitleChip

Returns TitleChip object from the given LayoutElement (e.g. one retrieved from a container's content with container.getContents().get(index)) if that element can be converted to TitleChip.

@NonNull ChipColors

Returns chip color of this Chip.

@NonNull ModifiersBuilders.Clickable

Returns click event action associated with this Chip.

@Nullable TypeBuilders.StringProp

Returns content description of this TitleChip.

int

Returns the horizontal alignment of the content in this Chip.

@Nullable String

Returns icon id from this TitleChip if it has been added.

@NonNull String

Returns text content of this Chip.

@NonNull DimensionBuilders.ContainerDimension

Returns width of this Chip.

Public methods

fromLayoutElement

Added in 1.0.0
public static @Nullable TitleChip fromLayoutElement(@NonNull LayoutElementBuilders.LayoutElement element)

Returns TitleChip object from the given LayoutElement (e.g. one retrieved from a container's content with container.getContents().get(index)) if that element can be converted to TitleChip. Otherwise, it will return null.

getChipColors

Added in 1.0.0
public @NonNull ChipColors getChipColors()

Returns chip color of this Chip.

getClickable

Added in 1.0.0
public @NonNull ModifiersBuilders.Clickable getClickable()

Returns click event action associated with this Chip.

getContentDescription

Added in 1.2.0
public @Nullable TypeBuilders.StringProp getContentDescription()

Returns content description of this TitleChip.

getHorizontalAlignment

Added in 1.0.0
public int getHorizontalAlignment()

Returns the horizontal alignment of the content in this Chip.

getIconContent

Added in 1.0.0
public @Nullable String getIconContent()

Returns icon id from this TitleChip if it has been added. Otherwise, it returns null.

getText

Added in 1.0.0
public @NonNull String getText()

Returns text content of this Chip.

getWidth

Added in 1.0.0
public @NonNull DimensionBuilders.ContainerDimension getWidth()

Returns width of this Chip.