TextComponent
open class TextComponent(textStyle: TextStyle = TextStyle.Default, lineCount: Int = TEXT_COMPONENT_LINE_COUNT, textOverflow: TextOverflow = TextOverflow.Ellipsis, margins: Insets = Insets.Zero, padding: Insets = Insets.Zero, val background: Component? = null, minWidth: TextComponent.MinWidth = MinWidth.fixed())
Uses Canvas to render text. This class utilizes TextMeasurer and supports the following:
multi-line text with automatic line breaking
text truncation
text rotation
text backgrounds (any Component)
margins and padding
Constructors
Link copied to clipboard
constructor(textStyle: TextStyle = TextStyle.Default, lineCount: Int = TEXT_COMPONENT_LINE_COUNT, textOverflow: TextOverflow = TextOverflow.Ellipsis, margins: Insets = Insets.Zero, padding: Insets = Insets.Zero, background: Component? = null, minWidth: TextComponent.MinWidth = MinWidth.fixed())
Types
Link copied to clipboard
Defines a TextComponent’s minimum width.
Functions
Link copied to clipboard
open fun copy(style: TextStyle = this.textStyle, lineCount: Int = this.lineCount, textOverflow: TextOverflow = this.textOverflow, margins: Insets = this.margins, padding: Insets = this.padding, background: Component? = this.background, minWidth: TextComponent.MinWidth = this.minWidth): TextComponent
Creates a new TextComponent based on this one.
Link copied to clipboard
fun draw(context: DrawingContext, text: CharSequence, x: Float, y: Float, horizontalPosition: Position.Horizontal = Position.Horizontal.Center, verticalPosition: Position.Vertical = Position.Vertical.Center, maxWidth: Int = DEF_LAYOUT_SIZE, maxHeight: Int = DEF_LAYOUT_SIZE, rotationDegrees: Float = 0.0f)
Uses Canvas to draw this TextComponent.
Link copied to clipboard
fun getBounds(context: MeasuringContext, text: CharSequence? = null, maxWidth: Int = DEF_LAYOUT_SIZE, maxHeight: Int = DEF_LAYOUT_SIZE, rotationDegrees: Float = 0.0f, pad: Boolean = text == null): Rect
Link copied to clipboard
fun getHeight(context: MeasuringContext, text: CharSequence? = null, maxWidth: Int = DEF_LAYOUT_SIZE, maxHeight: Int = DEF_LAYOUT_SIZE, rotationDegrees: Float = 0.0f, pad: Boolean = text == null): Float
Returns the height of this TextComponent for the given text and maximum dimensions. pad defines whether to extend text by such a number of blank lines that it has lineCount lines.
Link copied to clipboard
fun getWidth(context: MeasuringContext, text: CharSequence? = null, maxWidth: Int = DEF_LAYOUT_SIZE, maxHeight: Int = DEF_LAYOUT_SIZE, rotationDegrees: Float = 0.0f, pad: Boolean = text == null): Float
Returns the width of this TextComponent for the given text and maximum dimensions. pad defines whether to extend text by such a number of blank lines that it has lineCount lines.