TextKt
public final class TextKt
Summary
Public methods |
|
---|---|
static final @NonNull LayoutElementBuilders.Text |
basicText( Builds a text string. |
static final @NonNull LayoutElementBuilders.FontStyle |
fontStyle( Builds the styling of a font (e.g. font size, and metrics). |
Public methods
basicText
public static final @NonNull LayoutElementBuilders.Text basicText(
@NonNull LayoutString text,
LayoutElementBuilders.FontStyle fontStyle,
LayoutModifier modifier,
int maxLines,
int alignment,
int overflow,
@Dimension(unit = 2) float lineHeight
)
Builds a text string.
Parameters | |
---|---|
@NonNull LayoutString text |
The text to render. |
LayoutElementBuilders.FontStyle fontStyle |
The style of font to use (size, bold etc). If not specified, defaults to the platform's default body font. |
LayoutModifier modifier |
Modifiers to set to this element.. |
int maxLines |
The maximum number of lines that can be represented by the |
int alignment |
Alignment of the text within its bounds. Note that a |
int overflow |
How to handle text which overflows the bound of the |
@Dimension(unit = 2) float lineHeight |
The explicit height between lines of text. This is equivalent to the vertical distance between subsequent baselines. If not specified, defaults the font's recommended interline spacing. |
fontStyle
public static final @NonNull LayoutElementBuilders.FontStyle fontStyle(
@Dimension(unit = 2) float size,
boolean italic,
boolean underline,
LayoutColor color,
int weight,
float letterSpacingEm,
@RequiresSchemaVersion(major = 1, minor = 300) @NonNull List<@NonNull Float> additionalSizesSp,
@RequiresSchemaVersion(major = 1, minor = 400) @NonNull List<@NonNull LayoutElementBuilders.FontSetting> settings,
@RequiresSchemaVersion(major = 1, minor = 400) @NonNull List<@NonNull String> preferredFontFamilies
)
Builds the styling of a font (e.g. font size, and metrics).
Parameters | |
---|---|
@Dimension(unit = 2) float size |
The size of the font, in scaled pixels (sp). If not specified, defaults to the size of the system's "body" font. |
boolean italic |
Whether the text should be rendered in a italic typeface. |
boolean underline |
Whether the text should be rendered with an underline. |
LayoutColor color |
The text color. If not defined, defaults to white. |
int weight |
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". |
float letterSpacingEm |
The text letter-spacing. Positive numbers increase the space between letters while negative numbers tighten the space. If not specified, defaults to 0. |
@RequiresSchemaVersion(major = 1, minor = 300) @NonNull List<@NonNull Float> additionalSizesSp |
when this |
@RequiresSchemaVersion(major = 1, minor = 400) @NonNull List<@NonNull LayoutElementBuilders.FontSetting> settings |
The collection of font settings to be applied. If more than one Setting with the same axis tag is specified, the first one will be used. Supported settings depend on the font used by the system and the renderer version. However, if using |
@RequiresSchemaVersion(major = 1, minor = 400) @NonNull List<@NonNull String> preferredFontFamilies |
is the ordered list of font families to pick from for this |