content: String
TextView
A view that displays text with automatic sizing and alignment options.
TextView wraps a Text visual and provides additional layout features:
- Automatic size computation based on text content
- Vertical and horizontal alignment within the view bounds
- Text wrapping with fitWidth support
- Padding support for text positioning
- Special centering option for single-line text
This is the preferred way to display text within UI layouts as it properly integrates with the View sizing system.
var label = new TextView();
label.content = "Hello World";
label.font = myFont;
label.textColor = Color.WHITE;
label.align = CENTER;
label.verticalAlign = CENTER;
label.viewSize(200, 50); // Text centered in 200x50 area
Instance Members
The underlying Text visual that renders the actual text. This is automatically created and managed by the TextView.
Vertical alignment of the text within the view bounds.
- TOP: Align to top edge (plus padding)
- CENTER: Center vertically
- BOTTOM: Align to bottom edge (minus padding) Default: TOP
The bitmap font used to render the text. Changing the font will trigger a layout update.
Pre-rendered font size for performance optimization. See Text.preRenderedSize for details.
The color of the text. This is a convenience property that maps to text.color.
The alpha transparency of the text (0.0 to 1.0). This is a convenience property that maps to text.alpha.
The text content to display. Supports multiline text with \n line breaks. Setting this will trigger a layout update.
The point size of the text. This scales the font size relative to the font's native size. Setting this will trigger a layout update.
Minimum height for the view. The view will not be smaller than this height even if the text is shorter. Default: 0
Line height multiplier for text spacing. Values > 1.0 increase space between lines. Values < 1.0 decrease space between lines.
Additional spacing between letters in pixels. Positive values increase spacing, negative values decrease it.
Horizontal text alignment within the view.
- LEFT: Align text to the left
- CENTER: Center text horizontally
- RIGHT: Align text to the right
If true, automatically centers the text horizontally when it's only one line. This overrides the align property for single-line text. Useful for buttons or labels that should center short text. Default: false
Maximum line width difference ratio for text wrapping. Controls how evenly lines are distributed when wrapping. See Text.maxLineDiff for details.
If true, disables automatic text wrapping based on view width. The text will render on a single line unless it contains explicit line breaks. Default: false
computeSize(parentWidth: Float, parentHeight: Float, layoutMask: ViewLayoutMask, persist: Bool): Void
Compute the size of the view based on text content. This method automatically sizes the view to fit the text, respecting any explicit width/height constraints.
Name | Type |
---|---|
parentWidth |
Float |
parentHeight |
Float |
layoutMask |
ViewLayoutMask |
persist |
Bool |
Create a new TextView. Automatically creates the underlying Text visual with sensible defaults.
Private Members
Position the text within the view based on alignment settings. Handles all combinations of vertical and horizontal alignment, taking padding into account.
Metadata
Name | Parameters |
---|---|
:build |
ceramic.macros.EntityMacro.buildForCompletion() |
:autoBuild |
ceramic.macros.EntityMacro.buildForCompletion() |
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |