public final class

Chip.Builder

extends java.lang.Object

implements LayoutElementBuilders.LayoutElement.Builder

 java.lang.Object

↳androidx.wear.tiles.material.Chip.Builder

Overview

Builder class for Chip.

Summary

Constructors
publicBuilder(Context context, ModifiersBuilders.Clickable clickable, DeviceParametersBuilders.DeviceParameters deviceParameters)

Creates a builder for the Chip with associated action.

Methods
public Chipbuild()

Constructs and returns Chip with the provided content and look.

public Chip.BuildersetChipColors(ChipColors chipColors)

Sets the colors for the Chip.

public Chip.BuildersetContentDescription(java.lang.CharSequence contentDescription)

Sets the content description for the Chip.

public Chip.BuildersetCustomContent(LayoutElementBuilders.LayoutElement content)

Sets the custom content for the Chip.

public Chip.BuildersetHorizontalAlignment(int horizontalAlignment)

Sets the horizontal alignment in the chip.

public Chip.BuildersetIconContent(java.lang.String imageResourceId)

Sets the icon for the Chip.

public Chip.BuildersetPrimaryLabelContent(java.lang.String primaryLabel)

Sets the primary label for the Chip.

public Chip.BuildersetSecondaryLabelContent(java.lang.String secondaryLabel)

Sets the secondary label for the Chip.

public Chip.BuildersetWidth(DimensionBuilders.ContainerDimension width)

Sets the width of Chip.

public Chip.BuildersetWidth(float width)

Sets the width of TitleChip.

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

Constructors

public Builder(Context context, ModifiersBuilders.Clickable clickable, DeviceParametersBuilders.DeviceParameters deviceParameters)

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

Parameters:

context: The application's context.
clickable: Associated for click events. When the Chip is clicked it will fire the associated action.
deviceParameters: The device parameters used to derive defaults for this Chip.

Methods

Sets the width of Chip. If not set, default value will be set to fill the screen.

public Chip.Builder setWidth(float width)

Sets the width of TitleChip. If not set, default value will be set to fill the screen.

public Chip.Builder setCustomContent(LayoutElementBuilders.LayoutElement content)

Sets the custom content for the Chip. Any previously added content will be overridden.

public Chip.Builder setContentDescription(java.lang.CharSequence contentDescription)

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

public Chip.Builder setPrimaryLabelContent(java.lang.String primaryLabel)

Sets the primary label for the Chip. Any previously added custom content will be overridden. Primary label can be on 1 or 2 lines, depending on the length and existence of secondary label.

public Chip.Builder setSecondaryLabelContent(java.lang.String 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(String).

public Chip.Builder setIconContent(java.lang.String imageResourceId)

Sets the icon for the Chip. Any previously added custom content will be overridden. Provided icon will be tinted to the given content color from ChipColors. This icon should be image with chosen alpha channel and not an actual image. If icon is set, primary label must be set too with Chip.Builder.setPrimaryLabelContent(String).

public Chip.Builder setChipColors(ChipColors chipColors)

Sets the colors for the Chip. If set, ChipColors.getBackgroundColor() will be used for the background of the button, ChipColors.getContentColor() for main text, ChipColors.getSecondaryContentColor() for label text and ChipColors.getIconColor() will be used as color for the icon itself. If not set, ChipDefaults.PRIMARY_COLORS will be used.

public Chip.Builder setHorizontalAlignment(int horizontalAlignment)

Sets the horizontal alignment in the chip. It is strongly recommended that the content of the chip is start-aligned if there is more than primary text in it. By default, LayoutElementBuilders.HORIZONTAL_ALIGN_CENTER will be used when only a primary label is present. Otherwise LayoutElementBuilders.HORIZONTAL_ALIGN_START will be used.

public Chip build()

Constructs and returns Chip with the provided content and look.