CompactChip.Builder


public final class CompactChip.Builder


Builder class for androidx.wear.protolayout.material.CompactChip.

Summary

Public constructors

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

Creates a builder for the CompactChip with associated action and the given text

Public methods

@NonNull CompactChip

Constructs and returns CompactChip with the provided content and look.

@NonNull CompactChip.Builder

Sets the colors for the CompactChip.

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

Sets the icon for the CompactChip.

Public constructors

Builder

Added in 1.0.0
public Builder(
    @NonNull Context context,
    @NonNull String text,
    @NonNull ModifiersBuilders.Clickable clickable,
    @NonNull DeviceParametersBuilders.DeviceParameters deviceParameters
)

Creates a builder for the CompactChip with associated action and the given text

Parameters
@NonNull Context context

The application's context.

@NonNull String text

The text to be displayed in this compact chip.

@NonNull ModifiersBuilders.Clickable clickable

Associated Clickable for click events. When the CompactChip is clicked it will fire the associated action.

@NonNull DeviceParametersBuilders.DeviceParameters deviceParameters

The device parameters used for styling text.

Public methods

build

Added in 1.0.0
public @NonNull CompactChip build()

Constructs and returns CompactChip with the provided content and look.

setChipColors

Added in 1.0.0
public @NonNull CompactChip.Builder setChipColors(@NonNull ChipColors chipColors)

Sets the colors for the CompactChip. If set, getBackgroundColor will be used for the background of the button and getContentColor for the text. If not set, COMPACT_PRIMARY_COLORS will be used.

setIconContent

Added in 1.0.0
public @NonNull CompactChip.Builder setIconContent(@NonNull String imageResourceId)

Sets the icon for the CompactChip. Provided icon will be tinted to the given content color from ChipColors. This icon should be image with chosen alpha channel that can be tinted.