Chip

Added in 1.1.0
Deprecated in 1.2.0

class Chip : LayoutElementBuilders.LayoutElement


Tiles component Chip that represents clickable object with the text, optional label and optional icon or with custom content.

The Chip is Stadium shape and has a max height designed to take no more than two lines of text of TYPOGRAPHY_BUTTON style. The Chip can have an icon horizontally parallel to the two lines of text. Width of chip can very, and the recommended size is screen dependent with the recommended margin being applied.

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

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

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

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

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

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

if this Chip is used inside of androidx.wear.tiles.material.layouts.PrimaryLayout.

Summary

Nested types

This class is deprecated. Deprecated in Java

Public functions

java-static Chip?

This function is deprecated. Deprecated in Java

ChipColors

This function is deprecated. Deprecated in Java

ModifiersBuilders.Clickable

This function is deprecated. Deprecated in Java

CharSequence?

This function is deprecated. Deprecated in Java

LayoutElementBuilders.LayoutElement?

This function is deprecated. Deprecated in Java

DimensionBuilders.ContainerDimension

This function is deprecated. Deprecated in Java

Int

This function is deprecated. Deprecated in Java

String?

This function is deprecated. Deprecated in Java

String?

This function is deprecated. Deprecated in Java

String?

This function is deprecated. Deprecated in Java

DimensionBuilders.ContainerDimension

This function is deprecated. Deprecated in Java

Public functions

fromLayoutElement

Added in 1.1.0
Deprecated in 1.2.0
java-static fun fromLayoutElement(element: LayoutElementBuilders.LayoutElement): Chip?

Returns Chip 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 Chip. Otherwise, it will return null.

getChipColors

Added in 1.1.0
Deprecated in 1.2.0
fun getChipColors(): ChipColors

Returns chip colors of this Chip.

getClickable

Added in 1.1.0
Deprecated in 1.2.0
fun getClickable(): ModifiersBuilders.Clickable

Returns click event action associated with this Chip.

getContentDescription

Added in 1.1.0
Deprecated in 1.2.0
fun getContentDescription(): CharSequence?

Returns content description of this Chip.

getCustomContent

Added in 1.1.0
Deprecated in 1.2.0
fun getCustomContent(): LayoutElementBuilders.LayoutElement?

Returns custom content from this Chip if it has been added. Otherwise, it returns null.

getHeight

Added in 1.1.0
Deprecated in 1.2.0
fun getHeight(): DimensionBuilders.ContainerDimension

Returns height of this Chip.

getHorizontalAlignment

Added in 1.1.0
Deprecated in 1.2.0
fun getHorizontalAlignment(): Int

Returns the horizontal alignment of the content in this Chip.

getIconContent

Added in 1.1.0
Deprecated in 1.2.0
fun getIconContent(): String?

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

getPrimaryLabelContent

Added in 1.1.0
Deprecated in 1.2.0
fun getPrimaryLabelContent(): String?

Returns primary label from this Chip if it has been added. Otherwise, it returns null.

getSecondaryLabelContent

Added in 1.1.0
Deprecated in 1.2.0
fun getSecondaryLabelContent(): String?

Returns secondary label from this Chip if it has been added. Otherwise, it returns null.

getWidth

Added in 1.1.0
Deprecated in 1.2.0
fun getWidth(): DimensionBuilders.ContainerDimension

Returns width of this Chip.