public final class Chip.Builder


Builder class for Chip.

Summary

Public constructors

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

Creates a builder for the Chip with associated action.

Public methods

@NonNull Chip

Constructs and returns Chip with the provided content and look.

@NonNull Chip.Builder

Sets the colors for the Chip.

@NonNull Chip.Builder

Sets the static content description for the Chip.

@NonNull Chip.Builder

Sets the content description for the Chip.

@NonNull Chip.Builder

Sets the custom content for the Chip.

@NonNull Chip.Builder
setHorizontalAlignment(int horizontalAlignment)

Sets the horizontal alignment in the chip.

@NonNull Chip.Builder
setIconContent(@NonNull String imageResourceId)

Sets the icon for the Chip.

@NonNull Chip.Builder

Sets the primary label for the Chip.

@NonNull Chip.Builder

Sets the secondary label for the Chip.

@NonNull Chip.Builder

Sets the width of Chip.

@NonNull Chip.Builder
setWidth(@Dimension(unit = 0) float width)

Sets the width of Chip.

Public constructors

Builder

Added in 1.0.0
public Builder(
    @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

build

Added in 1.0.0
public @NonNull Chip build()

Constructs and returns Chip with the provided content and look.

setChipColors

Added in 1.0.0
public @NonNull Chip.Builder setChipColors(@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.

setContentDescription

Added in 1.0.0
public @NonNull Chip.Builder setContentDescription(@NonNull CharSequence contentDescription)

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

setContentDescription

Added in 1.0.0
public @NonNull Chip.Builder setContentDescription(
    @NonNull 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).

setCustomContent

Added in 1.0.0
public @NonNull Chip.Builder setCustomContent(@NonNull LayoutElementBuilders.LayoutElement content)

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

setHorizontalAlignment

Added in 1.0.0
public @NonNull 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, HORIZONTAL_ALIGN_CENTER will be used when only a primary label is present. Otherwise HORIZONTAL_ALIGN_START will be used.

setIconContent

Added in 1.0.0
public @NonNull Chip.Builder setIconContent(@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 . 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.

setPrimaryLabelContent

Added in 1.0.0
public @NonNull Chip.Builder setPrimaryLabelContent(@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.

setSecondaryLabelContent

Added in 1.0.0
public @NonNull Chip.Builder setSecondaryLabelContent(@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.

setWidth

Added in 1.0.0
public @NonNull Chip.Builder setWidth(@NonNull DimensionBuilders.ContainerDimension width)

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

setWidth

Added in 1.0.0
public @NonNull Chip.Builder setWidth(@Dimension(unit = 0) float width)

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