TextView

EntityVisualQuadLayerViewceramic.TextView (Class) → elements.Button, elements.EntypoIconView, elements.LabelView

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
See: Text The underlying text visual, View The base view class

Instance Members

ui
text: Text

The underlying Text visual that renders the actual text. This is automatically created and managed by the TextView.


ui
verticalAlign: Anonymous

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

ui
font: BitmapFont

The bitmap font used to render the text. Changing the font will trigger a layout update.


ui
preRenderedSize: Int

Pre-rendered font size for performance optimization. See Text.preRenderedSize for details.


ui
textColor: Color

The color of the text. This is a convenience property that maps to text.color.


ui
textAlpha: Float

The alpha transparency of the text (0.0 to 1.0). This is a convenience property that maps to text.alpha.


ui
content: String

The text content to display. Supports multiline text with \n line breaks. Setting this will trigger a layout update.


ui
pointSize: Float

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.


ui
minHeight: Float

Minimum height for the view. The view will not be smaller than this height even if the text is shorter. Default: 0


ui
lineHeight: Float

Line height multiplier for text spacing. Values > 1.0 increase space between lines. Values < 1.0 decrease space between lines.


ui
letterSpacing: Float

Additional spacing between letters in pixels. Positive values increase spacing, negative values decrease it.


ui
align: Anonymous

Horizontal text alignment within the view.

  • LEFT: Align text to the left
  • CENTER: Center text horizontally
  • RIGHT: Align text to the right

ui
centerIfOneLine: Bool

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


ui
maxLineDiff: Float

Maximum line width difference ratio for text wrapping. Controls how evenly lines are distributed when wrapping. See Text.maxLineDiff for details.


ui
noFitWidth: Bool

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


ui
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

ui
new(): Void

Create a new TextView. Automatically creates the underlying Text visual with sensible defaults.

Private Members

ui
layout(): Void

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