Text
public class Text implements LayoutElementBuilders.LayoutElement
ProtoLayout component Text that represents text object holding any information.
There are pre-built typography styles that can be obtained from constants in FontStyle.
When accessing the contents of a container for testing, note that this element can't be simply casted back to the original type, i.e.:
Text text = new Text... Box box = new Box.Builder().addContent(text).build(); Text myText = (Text) box.getContents().get(0);
To be able to get Text object from any layout element, fromLayoutElement method should be used, i.e.:
Text myText = Text.fromLayoutElement(box.getContents().get(0));
Summary
Nested types |
|---|
public final class Text.BuilderBuilder class for |
Public methods |
|
|---|---|
static @Nullable Text |
Returns Material Text object from the given LayoutElement (e.g. one retrieved from a container's content with |
@NonNull ColorBuilders.ColorProp |
getColor()Returns the color of this Text element. |
@NonNull LayoutElementBuilders.FontStyle |
Returns the font style of this Text element. |
float |
Returns the line height of this Text element. |
int |
Returns the max lines of text of this Text element. |
@NonNull ModifiersBuilders.Modifiers |
Returns the modifiers of this Text element. |
int |
Returns the multiline alignment of this Text element. |
int |
Returns the overflow of this Text element. |
@NonNull TypeBuilders.StringProp |
getText()Returns the text of this Text element. |
int |
Returns the overflow of this Text element. |
boolean |
isItalic()Returns whether the Text is in italic. |
boolean |
Returns whether the Text is underlined. |
Public methods
fromLayoutElement
public static @Nullable Text fromLayoutElement(@NonNull LayoutElementBuilders.LayoutElement element)
Returns Material Text object from the given LayoutElement (e.g. one retrieved from a container's content with container.getContents().get(index)) if that element can be converted to Material Text. Otherwise, it will return null.
getColor
public @NonNull ColorBuilders.ColorProp getColor()
Returns the color of this Text element.
getFontStyle
public @NonNull LayoutElementBuilders.FontStyle getFontStyle()
Returns the font style of this Text element.
getLineHeight
public float getLineHeight()
Returns the line height of this Text element.
getMaxLines
public int getMaxLines()
Returns the max lines of text of this Text element.
getModifiers
public @NonNull ModifiersBuilders.Modifiers getModifiers()
Returns the modifiers of this Text element.
getMultilineAlignment
public int getMultilineAlignment()
Returns the multiline alignment of this Text element.
getText
public @NonNull TypeBuilders.StringProp getText()
Returns the text of this Text element.