Chip.Builder
class Chip.Builder : LayoutElementBuilders.LayoutElement.Builder
Builder class for androidx.wear.tiles.material.Chip.
Summary
Public constructors |
|---|
Creates a builder for the |
Public functions |
|
|---|---|
Chip |
Constructs and returns |
Chip.Builder |
Sets the colors for the |
Chip.Builder |
Sets the content description for the |
Chip.Builder |
Sets the custom content for the |
Chip.Builder |
Sets the horizontal alignment in the chip. |
Chip.Builder |
Sets the icon for the |
Chip.Builder |
Sets the primary label for the |
Chip.Builder |
Sets the secondary label for the |
Chip.Builder |
Sets the width of |
Chip.Builder |
Sets the width of |
Public constructors
Builder(
context: Context,
clickable: ModifiersBuilders.Clickable,
deviceParameters: DeviceParametersBuilders.DeviceParameters
)
Creates a builder for the Chip with associated action. It is required to add content later with setters.
| Parameters | |
|---|---|
context: Context |
The application's context. |
clickable: ModifiersBuilders.Clickable |
Associated Clickable for click events. When the Chip is clicked it will fire the associated action. |
deviceParameters: DeviceParametersBuilders.DeviceParameters |
The device parameters used to derive defaults for this Chip. |
Public functions
funsetChipColors(chipColors: ChipColors): Chip.Builder
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.
funsetContentDescription(contentDescription: CharSequence): Chip.Builder
Sets the content description for the Chip. It is highly recommended to provide this for chip containing icon.
funsetCustomContent(content: LayoutElementBuilders.LayoutElement): Chip.Builder
Sets the custom content for the Chip. Any previously added content will be overridden.
funsetHorizontalAlignment(horizontalAlignment: Int): Chip.Builder
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.
funsetIconContent(imageResourceId: String): Chip.Builder
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.
funsetPrimaryLabelContent(primaryLabel: String): Chip.Builder
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.
funsetSecondaryLabelContent(secondaryLabel: String): Chip.Builder
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.
funsetWidth(width: DimensionBuilders.ContainerDimension): Chip.Builder
Sets the width of Chip. If not set, default value will be set to fill the screen.