PrimaryLayout.Builder

Added in 1.1.0
Deprecated in 1.2.0

public final class PrimaryLayout.Builder implements LayoutElementBuilders.LayoutElement.Builder


Builder class for PrimaryLayout.

Summary

Public constructors

Creates a builder for the PrimaryLayout from the given content.

Public methods

@NonNull PrimaryLayout

Constructs and returns PrimaryLayout with the provided content and look.

@NonNull PrimaryLayout.Builder

Sets the additional content to this layout, above the primary chip.

@NonNull PrimaryLayout.Builder

Sets the element which is in the slot at the bottom of the layout.

@NonNull PrimaryLayout.Builder

Sets the content in the primary label slot which will be above the main content.

@NonNull PrimaryLayout.Builder

Sets the content in the primary label slot which will be below the main content.

@NonNull PrimaryLayout.Builder
setVerticalSpacerHeight(@Dimension(unit = 0) float height)

Sets the vertical spacer height which is used as a space between main content and secondary label if there is any.

Public constructors

Builder

Added in 1.1.0
Deprecated in 1.2.0
public Builder(
    @NonNull DeviceParametersBuilders.DeviceParameters deviceParameters
)

Creates a builder for the PrimaryLayout from the given content. Content inside of it can later be set with setContent, setPrimaryChipContent, setPrimaryLabelTextContent and setSecondaryLabelTextContent.

Public methods

build

Added in 1.1.0
Deprecated in 1.2.0
public @NonNull PrimaryLayout build()

Constructs and returns PrimaryLayout with the provided content and look.

setContent

Added in 1.1.0
Deprecated in 1.2.0
public @NonNull PrimaryLayout.Builder setContent(@NonNull LayoutElementBuilders.LayoutElement content)

Sets the additional content to this layout, above the primary chip.

The content slot will wrap the elements' height, so the height of the given content must be fixed or set to wrap (expand can't be used).

This layout has built-in horizontal margins, so the given content should have width set to expand to use all the available space, rather than an explicit width which may lead to clipping.

setPrimaryChipContent

Added in 1.1.0
Deprecated in 1.2.0
public @NonNull PrimaryLayout.Builder setPrimaryChipContent(
    @NonNull LayoutElementBuilders.LayoutElement compactChip
)

Sets the element which is in the slot at the bottom of the layout. Note that it is accepted to pass in any androidx.wear.tiles.LayoutElementBuilders.LayoutElement, but it is strongly recommended to add a CompactChip as the layout is optimized for it.

setPrimaryLabelTextContent

Added in 1.1.0
Deprecated in 1.2.0
public @NonNull PrimaryLayout.Builder setPrimaryLabelTextContent(
    @NonNull LayoutElementBuilders.LayoutElement primaryLabelText
)

Sets the content in the primary label slot which will be above the main content.

setSecondaryLabelTextContent

Added in 1.1.0
Deprecated in 1.2.0
public @NonNull PrimaryLayout.Builder setSecondaryLabelTextContent(
    @NonNull LayoutElementBuilders.LayoutElement secondaryLabelText
)

Sets the content in the primary label slot which will be below the main content. It is highly recommended to have primary label set when having secondary label.

setVerticalSpacerHeight

Added in 1.1.0
Deprecated in 1.2.0
public @NonNull PrimaryLayout.Builder setVerticalSpacerHeight(@Dimension(unit = 0) float height)

Sets the vertical spacer height which is used as a space between main content and secondary label if there is any. If not set, DEFAULT_VERTICAL_SPACER_HEIGHT will be used.