public final class

Chip.Builder

extends java.lang.Object

implements LayoutElementBuilders.LayoutElement.Builder

 java.lang.Object

↳androidx.wear.protolayout.materialcore.Chip.Builder

Overview

Builder class for Chip.

Summary

Fields
public static final intCUSTOM_CONTENT

Chip type to be used when setting a content which is a custom one.

public static final intICON

Chip type to be used when setting a content which has an icon.

public static final intNOT_SET

Chip type that has no inner set.

public static final intTEXT

Chip type to be used when setting a content which has a text.

Constructors
publicBuilder(ModifiersBuilders.Clickable clickable)

Creates a builder for the Chip with associated action.

Methods
public Chipbuild()

Constructs and returns Chip with the provided content and look.

public Chip.BuildersetBackgroundColor(ColorBuilders.ColorProp backgroundColor)

Sets the background colors for the Button.

public Chip.BuildersetContentDescription(TypeBuilders.StringProp contentDescription)

Sets the content description for the Chip.

public Chip.BuildersetCustomContent(LayoutElementBuilders.LayoutElement content)

Sets the custom content for the Chip.

public Chip.BuildersetHeight(DimensionBuilders.DpProp height)

Sets the height of Chip.

public Chip.BuildersetHorizontalAlignment(int horizontalAlignment)

Sets the horizontal alignment in the chip.

public Chip.BuildersetHorizontalPadding(DimensionBuilders.DpProp horizontalPadding)

Sets the horizontal padding in the chip.

public Chip.BuildersetIconContent(LayoutElementBuilders.LayoutElement imageResourceId)

Sets the icon for the Chip.

public Chip.BuildersetIconSpacerWidth(DimensionBuilders.DpProp iconSpacerWidth)

Sets the width of spacer used next to the icon if set.

public Chip.BuildersetMinimalTappableSquareLength(DimensionBuilders.DpProp tappableLength)

Sets the length of minimal tappable square for this chip.

public Chip.BuildersetPrimaryLabelContent(LayoutElementBuilders.LayoutElement primaryLabel)

Sets the primary label for the Chip.

public Chip.BuildersetSecondaryLabelContent(LayoutElementBuilders.LayoutElement secondaryLabel)

Sets the secondary label for the Chip.

public Chip.BuildersetWidth(DimensionBuilders.ContainerDimension width)

Sets the width of Chip.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Fields

public static final int NOT_SET

Chip type that has no inner set.

public static final int TEXT

Chip type to be used when setting a content which has a text.

public static final int ICON

Chip type to be used when setting a content which has an icon.

public static final int CUSTOM_CONTENT

Chip type to be used when setting a content which is a custom one.

Constructors

public Builder(ModifiersBuilders.Clickable clickable)

Creates a builder for the Chip with associated action. It is required to add content later with setters.

Parameters:

clickable: Associated ModifiersBuilders.Clickable for click events. When the Chip is clicked it will fire the associated action.

Methods

Sets the width of Chip. If not set, Chip won't be shown.

public Chip.Builder setHeight(DimensionBuilders.DpProp height)

Sets the height of Chip. If not set, Chip won't be shown.

public Chip.Builder setCustomContent(LayoutElementBuilders.LayoutElement content)

Sets the custom content for the Chip. Any previously added content will be overridden. Provided content should be styled and sized.

public Chip.Builder setBackgroundColor(ColorBuilders.ColorProp backgroundColor)

Sets the background colors for the Button. If not set, black is used.

public Chip.Builder setContentDescription(TypeBuilders.StringProp contentDescription)

Sets the content description for the Chip. It is highly recommended to provide this for chip containing icon.

While this field is statically accessible from 1.0, it's only bindable since version 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).

public Chip.Builder setPrimaryLabelContent(LayoutElementBuilders.LayoutElement primaryLabel)

Sets the primary label for the Chip. Any previously added custom content will be overridden. This should be styled and sized by the caller.

public Chip.Builder setSecondaryLabelContent(LayoutElementBuilders.LayoutElement secondaryLabel)

Sets the secondary label for the Chip. Any previously added custom content will be overridden. If secondary label is set, primary label must be set too with Chip.Builder.setPrimaryLabelContent(LayoutElementBuilders.LayoutElement). This should be styled and sized by the caller.

public Chip.Builder setIconContent(LayoutElementBuilders.LayoutElement imageResourceId)

Sets the icon for the Chip. Any previously added custom content will be overridden. If icon is set, primary label must be set too with Chip.Builder.setPrimaryLabelContent(LayoutElementBuilders.LayoutElement). This should be styled and sized by the caller.

public Chip.Builder setHorizontalAlignment(int horizontalAlignment)

Sets the horizontal alignment in the chip. If not set, LayoutElementBuilders.HORIZONTAL_ALIGN_START will be used.

public Chip.Builder setIconSpacerWidth(DimensionBuilders.DpProp iconSpacerWidth)

Sets the width of spacer used next to the icon if set.

public Chip.Builder setMinimalTappableSquareLength(DimensionBuilders.DpProp tappableLength)

Sets the length of minimal tappable square for this chip.

public Chip.Builder setHorizontalPadding(DimensionBuilders.DpProp horizontalPadding)

Sets the horizontal padding in the chip.

public Chip build()

Constructs and returns Chip with the provided content and look.