public final class

PrimaryLayout.Builder

extends java.lang.Object

implements LayoutElementBuilders.LayoutElement.Builder

 java.lang.Object

↳androidx.wear.protolayout.material.layouts.PrimaryLayout.Builder

Overview

Builder class for PrimaryLayout.

Summary

Constructors
publicBuilder(DeviceParametersBuilders.DeviceParameters deviceParameters)

Creates a builder for the PrimaryLayout from the given content.

Methods
public PrimaryLayoutbuild()

Constructs and returns PrimaryLayout with the provided content and look.

public PrimaryLayout.BuildersetContent(LayoutElementBuilders.LayoutElement content)

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

public PrimaryLayout.BuildersetPrimaryChipContent(LayoutElementBuilders.LayoutElement compactChip)

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

public PrimaryLayout.BuildersetPrimaryLabelTextContent(LayoutElementBuilders.LayoutElement primaryLabelText)

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

public PrimaryLayout.BuildersetResponsiveContentInsetEnabled(boolean enabled)

Changes this PrimaryLayout to use responsive insets for its content (primary label, secondary label and primary bottom chip) by adding an additional space on the side of this element to avoid that content going off the screen edge.

public PrimaryLayout.BuildersetSecondaryLabelTextContent(LayoutElementBuilders.LayoutElement secondaryLabelText)

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

public PrimaryLayout.BuildersetVerticalSpacerHeight(float height)

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

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder(DeviceParametersBuilders.DeviceParameters deviceParameters)

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

For optimal layouts across different screen sizes, it is highly recommended to call PrimaryLayout.Builder.setResponsiveContentInsetEnabled(boolean).

Methods

public PrimaryLayout.Builder setResponsiveContentInsetEnabled(boolean enabled)

Changes this PrimaryLayout to use responsive insets for its content (primary label, secondary label and primary bottom chip) by adding an additional space on the side of this element to avoid that content going off the screen edge.

It is highly recommended to call this method with true when using this layout to optimize it for different screen sizes.

public PrimaryLayout.Builder setPrimaryChipContent(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 LayoutElementBuilders.LayoutElement, but it is strongly recommended to add a CompactChip as the layout is optimized for it.

public PrimaryLayout.Builder setPrimaryLabelTextContent(LayoutElementBuilders.LayoutElement primaryLabelText)

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

public PrimaryLayout.Builder setSecondaryLabelTextContent(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.

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.

public PrimaryLayout.Builder setVerticalSpacerHeight(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, LayoutDefaults.DEFAULT_VERTICAL_SPACER_HEIGHT will be used.

public PrimaryLayout build()

Constructs and returns PrimaryLayout with the provided content and look.