Chip.Builder
public final class Chip.Builder implements LayoutElementBuilders.LayoutElement.Builder
Builder class for androidx.wear.tiles.material.Chip.
Summary
Public constructors |
|---|
Creates a builder for the |
Public methods |
|
|---|---|
@NonNull Chip |
Constructs and returns |
@NonNull Chip.Builder |
Sets the colors for the |
@NonNull Chip.Builder |
Sets the content description for the |
@NonNull Chip.Builder |
Sets the custom content for the |
@NonNull Chip.Builder |
Sets the horizontal alignment in the chip. |
@NonNull Chip.Builder |
Sets the icon for the |
@NonNull Chip.Builder |
Sets the primary label for the |
@NonNull Chip.Builder |
Sets the secondary label for the |
@NonNull Chip.Builder |
Sets the width of |
@NonNull Chip.Builder |
Sets the width of |
Public constructors
publicBuilder(
@NonNull Context context,
@NonNull ModifiersBuilders.Clickable clickable,
@NonNull DeviceParametersBuilders.DeviceParameters deviceParameters
)
Creates a builder for the Chip with associated action. It is required to add content later with setters.
| Parameters | |
|---|---|
@NonNull Context context |
The application's context. |
@NonNull ModifiersBuilders.Clickable clickable |
Associated Clickable for click events. When the Chip is clicked it will fire the associated action. |
@NonNull DeviceParametersBuilders.DeviceParameters deviceParameters |
The device parameters used to derive defaults for this Chip. |
Public methods
public @NonNull Chip.BuildersetChipColors(@NonNull ChipColors chipColors)
Sets the colors for the Chip. If set, getBackgroundColor will be used for the background of the button, getContentColor for main text, getSecondaryContentColor for label text and getIconColor will be used as color for the icon itself. If not set, PRIMARY_COLORS will be used.
public @NonNull Chip.BuildersetContentDescription(@NonNull CharSequence contentDescription)
Sets the content description for the Chip. It is highly recommended to provide this for chip containing icon.
public @NonNull Chip.BuildersetCustomContent(@NonNull LayoutElementBuilders.LayoutElement content)
Sets the custom content for the Chip. Any previously added content will be overridden.
public @NonNull Chip.BuildersetHorizontalAlignment(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, HORIZONTAL_ALIGN_CENTER will be used when only a primary label is present. Otherwise HORIZONTAL_ALIGN_START will be used.
public @NonNull Chip.BuildersetIconContent(@NonNull 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 setPrimaryLabelContent.
public @NonNull Chip.BuildersetPrimaryLabelContent(@NonNull 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 @NonNull Chip.BuildersetSecondaryLabelContent(@NonNull 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 setPrimaryLabelContent.
public @NonNull Chip.BuildersetWidth(@NonNull DimensionBuilders.ContainerDimension width)
Sets the width of Chip. If not set, default value will be set to fill the screen.