public final class

LayoutElementBuilders.FontStyle.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.wear.protolayout.LayoutElementBuilders.FontStyle.Builder

Overview

Builder for LayoutElementBuilders.FontStyle

Summary

Constructors
publicBuilder()

Creates an instance of LayoutElementBuilders.FontWeightProp.Builder.

Methods
public LayoutElementBuilders.FontStylebuild()

Builds an instance from accumulated values.

public LayoutElementBuilders.FontStyle.BuildersetColor(ColorBuilders.ColorProp color)

Sets the text color.

public LayoutElementBuilders.FontStyle.BuildersetItalic(boolean italic)

Sets whether the text should be rendered in a italic typeface.

public LayoutElementBuilders.FontStyle.BuildersetItalic(TypeBuilders.BoolProp italic)

Sets whether the text should be rendered in a italic typeface.

public LayoutElementBuilders.FontStyle.BuildersetLetterSpacing(DimensionBuilders.EmProp letterSpacing)

Sets the text letter-spacing.

public LayoutElementBuilders.FontStyle.BuildersetPreferredFontFamilies(java.lang.String fontFamily, java.lang.String fallbacks[])

Sets the preferred font families for this LayoutElementBuilders.FontStyle.

public LayoutElementBuilders.FontStyle.BuildersetSettings(LayoutElementBuilders.FontSetting settings[])

Sets the collection of font settings to be applied.

public LayoutElementBuilders.FontStyle.BuildersetSize(DimensionBuilders.SpProp size)

Sets the size of the font, in scaled pixels (sp).

public LayoutElementBuilders.FontStyle.BuildersetSizes(int[] sizes[])

Sets the available sizes of the font, in scaled pixels (sp).

public LayoutElementBuilders.FontStyle.BuildersetUnderline(boolean underline)

Sets whether the text should be rendered with an underline.

public LayoutElementBuilders.FontStyle.BuildersetUnderline(TypeBuilders.BoolProp underline)

Sets whether the text should be rendered with an underline.

public LayoutElementBuilders.FontStyle.BuildersetVariant(int variant)

Sets the variant of a font.

public LayoutElementBuilders.FontStyle.BuildersetVariant(LayoutElementBuilders.FontVariantProp variant)

Sets the variant of a font.

public LayoutElementBuilders.FontStyle.BuildersetWeight(int weight)

Sets the weight of the font.

public LayoutElementBuilders.FontStyle.BuildersetWeight(LayoutElementBuilders.FontWeightProp weight)

Sets the weight of the font.

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

Constructors

public Builder()

Creates an instance of LayoutElementBuilders.FontWeightProp.Builder.

Methods

Sets whether the text should be rendered in a italic typeface. If not specified, defaults to "false".

Note that this field only supports static values.

public LayoutElementBuilders.FontStyle.Builder setItalic(boolean italic)

Sets whether the text should be rendered in a italic typeface. If not specified, defaults to "false".

Sets whether the text should be rendered with an underline. If not specified, defaults to "false".

Note that this field only supports static values.

public LayoutElementBuilders.FontStyle.Builder setUnderline(boolean underline)

Sets whether the text should be rendered with an underline. If not specified, defaults to "false".

Sets the text color. If not defined, defaults to white.

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).

Sets the weight of the font. If the provided value is not supported on a platform, the nearest supported value will be used. If not defined, or when set to an invalid value, defaults to "normal".

public LayoutElementBuilders.FontStyle.Builder setWeight(int weight)

Sets the weight of the font. If the provided value is not supported on a platform, the nearest supported value will be used. If not defined, or when set to an invalid value, defaults to "normal".

Sets the text letter-spacing. Positive numbers increase the space between letters while negative numbers tighten the space. If not specified, defaults to 0.

Sets the variant of a font. Some renderers may use different fonts for title and body text, which can be selected using this field. If not specified, defaults to "body".

public LayoutElementBuilders.FontStyle.Builder setVariant(int variant)

Sets the variant of a font. Some renderers may use different fonts for title and body text, which can be selected using this field. If not specified, defaults to "body".

public LayoutElementBuilders.FontStyle.Builder setSizes(int[] sizes[])

Sets the available sizes of the font, in scaled pixels (sp). If not specified, defaults to the size of the system's "body" font.

If more than one size is specified and this LayoutElementBuilders.FontStyle is applied to a LayoutElementBuilders.Text element with static text, the text size will be automatically picked from the provided sizes to try to perfectly fit within its parent bounds. In other words, the largest size from the specified preset sizes that can fit the most text within the parent bounds will be used.

The specified sizes don't have to be sorted, but they need to contain only positive values. The maximum number of sizes used is limited to 10.

Note that, if multiple sizes are set, the parent of the LayoutElementBuilders.Text element this corresponds to shouldn't have its width and height set to wrapped, as it can lead to unexpected results.

If this LayoutElementBuilders.FontStyle is set to any other element besides LayoutElementBuilders.Text or that LayoutElementBuilders.Text element has dynamic field, only the last added size will be used.

Any previously added values with this method or LayoutElementBuilders.FontStyle.Builder.setSize(DimensionBuilders.SpProp) will be cleared.

While this field is accessible from 1.0 as singular, it only accepts multiple values since version 1.3 and renderers supporting version 1.3 will use the multiple values to automatically scale text. Renderers who don't support this version will use the last size among multiple values.

Sets the size of the font, in scaled pixels (sp). If not specified, defaults to the size of the system's "body" font.

Any previously added values with this method or LayoutElementBuilders.FontStyle.Builder.setSizes(int...) will be cleared.

public LayoutElementBuilders.FontStyle.Builder setPreferredFontFamilies(java.lang.String fontFamily, java.lang.String fallbacks[])

Sets the preferred font families for this LayoutElementBuilders.FontStyle.

For example, preferring default system variable font with default non variable system font as a fallback.

If the given font family is not available on a device, the fallback values will be attempted to use, in order in which they are given.

Renderer support for values outside of the given constants (LayoutElementBuilders.FontStyle.ROBOTO_FONT or LayoutElementBuilders.FontStyle.ROBOTO_FLEX_FONT) is not guaranteed for all devices.

If not set, default system font will be used.

Parameters:

fontFamily: preferred font family name to be used if available
fallbacks: the ordered list of fallback font family to attempt to use if the preferred font family is not available.

Sets the collection of font settings to be applied. If more than one Setting with the same axis tag is added, the first one will be used.

Any previously added settings will be cleared.

Supported settings depend on the font used and renderer version. If this is used with the variable fonts on renderers supporting 1.4, LayoutElementBuilders.FontSetting.weight(int) and LayoutElementBuilders.FontSetting.width(float) setting will always be available.

Builds an instance from accumulated values.