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.BuildersetContent(LayoutElementBuilders.LayoutElement content)

Sets the custom content for the Chip.

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

Sets the content description for the Chip.

public Chip.BuildersetHorizontalAlignment(int horizontalAlignment)

Sets the horizontal alignment in the chip.

public Chip.BuildersetPrimaryTextContent(java.lang.String primaryText)

Sets the content of the Chip to be the given primary text.

public Chip.BuildersetPrimaryTextIconContent(java.lang.String primaryText, java.lang.String resourceId)

Sets the content of the Chip to be the given primary text with an icon and secondary label.

public Chip.BuildersetPrimaryTextLabelContent(java.lang.String primaryText, java.lang.String label)

Sets the content of the Chip to be the given primary text and secondary label.

public Chip.BuildersetPrimaryTextLabelIconContent(java.lang.String primaryText, java.lang.String label, java.lang.String resourceId)

Sets the content of the Chip to be the given primary text with an icon.

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 ModifiersBuilders.Clickable 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.

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 setPrimaryTextContent(java.lang.String primaryText)

Sets the content of the Chip to be the given primary text. Any previously added content will be overridden. Primary text can be on 1 or 2 lines, depending on the length.

public Chip.Builder setPrimaryTextLabelContent(java.lang.String primaryText, java.lang.String label)

Sets the content of the Chip to be the given primary text and secondary label. Any previously added content will be overridden. Primary text can be shown on 1 line only.

public Chip.Builder setPrimaryTextIconContent(java.lang.String primaryText, java.lang.String resourceId)

Sets the content of the Chip to be the given primary text with an icon and secondary label. Any previously added 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.

public Chip.Builder setPrimaryTextLabelIconContent(java.lang.String primaryText, java.lang.String label, java.lang.String resourceId)

Sets the content of the Chip to be the given primary text with an icon. Any previously added 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. Primary text can be shown on 1 line only.

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. If not set, LayoutElementBuilders.HORIZONTAL_ALIGN_START will be used.

public Chip build()

Constructs and returns Chip with the provided content and look.