public final class

Text.Builder

extends java.lang.Object

implements LayoutElementBuilders.LayoutElement.Builder

 java.lang.Object

↳androidx.wear.protolayout.material.Text.Builder

Overview

Builder class for Text.

Summary

Constructors
publicBuilder(Context context, java.lang.String text)

Creates a builder for a Text component with static text.

publicBuilder(Context context, TypeBuilders.StringProp text, TypeBuilders.StringLayoutConstraint stringLayoutConstraint)

Creates a builder for a Text.

Methods
public Textbuild()

Constructs and returns Text with the provided content and look.

public Text.BuildersetColor(ColorBuilders.ColorProp color)

Sets the color for the Text.

public Text.BuildersetItalic(boolean italic)

Sets the text to be italic.

public Text.BuildersetMaxLines(int maxLines)

Sets the maximum lines of text.

public Text.BuildersetModifiers(ModifiersBuilders.Modifiers modifiers)

Sets the modifiers of text.

public Text.BuildersetMultilineAlignment(int multilineAlignment)

Sets the multiline alignment for text within bounds of the Text element.

public Text.BuildersetOverflow(int overflow)

Sets the overflow for text.

public Text.BuildersetScalable(boolean isScalable)

Sets whether the text size will change if user has changed the default font size.

public Text.BuildersetTypography(int typography)

Sets the typography for the Text.

public Text.BuildersetUnderline(boolean underline)

Sets the text to be underlined.

public Text.BuildersetWeight(int weight)

Sets the weight of the font.

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

Constructors

public Builder(Context context, java.lang.String text)

Creates a builder for a Text component with static text.

Parameters:

context: The application's context.
text: The text content for this component.

public Builder(Context context, TypeBuilders.StringProp text, TypeBuilders.StringLayoutConstraint stringLayoutConstraint)

Creates a builder for a Text.

While this component 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).

Parameters:

context: The application's context.
text: The text content for this component.
stringLayoutConstraint: Layout constraints used to correctly measure Text view size and align text when text has dynamic value.

Methods

public Text.Builder setTypography(int typography)

Sets the typography for the Text. If not set, Typography.TYPOGRAPHY_DISPLAY1 will be used.

public Text.Builder setScalable(boolean isScalable)

Sets whether the text size will change if user has changed the default font size. If not set, true will be used.

public Text.Builder setColor(ColorBuilders.ColorProp color)

Sets the color for the Text. If not set, onPrimary color from the Colors.DEFAULT will be used.

public Text.Builder setItalic(boolean italic)

Sets the text to be italic. If not set, false will be used.

public Text.Builder setUnderline(boolean underline)

Sets the text to be underlined. If not set, false will be used.

public Text.Builder setMaxLines(int maxLines)

Sets the maximum lines of text. If not set, 1 will be used.

public Text.Builder setMultilineAlignment(int multilineAlignment)

Sets the multiline alignment for text within bounds of the Text element. Note that this option has no effect for single line of text, and for that, alignment on the outer container should be used. If not set, LayoutElementBuilders.TEXT_ALIGN_CENTER will be used.

public Text.Builder setModifiers(ModifiersBuilders.Modifiers modifiers)

Sets the modifiers of text.

public Text.Builder setOverflow(int overflow)

Sets the overflow for text. If not set, LayoutElementBuilders.TEXT_OVERFLOW_ELLIPSIZE_END will be used.

public Text.Builder setWeight(int weight)

Sets the weight of the font. If not set, default weight for the chosen Typography will be used.

public Text build()

Constructs and returns Text with the provided content and look.