LinearLayout

EntityVisualQuadLayerViewceramic.LinearLayout (Class) → ColumnLayout, RowLayout, elements.FieldView

A flexible layout container that arranges its children in a single line, either horizontally or vertically. Supports flexible sizing, spacing, alignment, and "fill" behavior for responsive layouts.

LinearLayout is the foundation for building structured UI layouts, allowing children to be arranged sequentially with automatic sizing based on content or available space.

var layout = new LinearLayout();
layout.direction = VERTICAL;
layout.itemSpacing = 10;
layout.align = CENTER;

// Add children with different sizing
var header = new TextView();
header.viewHeight = 50; // Fixed height

var content = new View();
content.viewHeight = fill(); // Takes remaining space
content.flex = 2; // Takes 2x space compared to other FILL views

layout.add(header);
layout.add(content);
See: RowLayout A horizontal-only variant, ColumnLayout A vertical-only variant, View The base class for all UI components

Instance Members

ui
direction: Anonymous

The layout direction determining how children are arranged.

  • VERTICAL: Children are stacked top-to-bottom
  • HORIZONTAL: Children are placed left-to-right

Changing direction automatically adjusts the alignment mode to match the new orientation.


ui
itemSpacing: Float

The spacing between child views in pixels. Can be a percentage value relative to the parent size along the layout axis (height for vertical, width for horizontal).

layout.itemSpacing = 10; // 10 pixels between items
layout.itemSpacing = PERCENT(5); // 5% of parent size

ui
align: Anonymous

Controls how children are aligned along the layout axis.

  • For VERTICAL layouts: TOP, CENTER, or BOTTOM
  • For HORIZONTAL layouts: LEFT, CENTER, or RIGHT

The alignment determines where children are positioned when they don't fill the entire available space.


ui
childrenDepth: ChildrenDepth

Controls how depth values are assigned to children for render ordering.

  • INCREMENT: First child gets depth 1, second gets 2, etc.
  • DECREMENT: First child gets highest depth, decreasing for each
  • SAME: All children get depth 1
  • CUSTOM: Depth values are managed manually

ui
computeSize(parentWidth: Float, parentHeight: Float, parentLayoutMask: ViewLayoutMask, persist: Bool): Void

Computes the size of this layout based on its children and constraints. Handles both fixed and flexible (FILL) sized children, respecting padding and spacing. The computation differs based on layout direction.

Name Type Description
parentWidth Float Available width from parent
parentHeight Float Available height from parent
parentLayoutMask ViewLayoutMask Constraints from parent layout
persist Bool Whether to save computed sizes for layout phase

ui
new(): Void

Creates a new LinearLayout instance. By default, the layout is transparent and arranges children vertically.

Private Members

ui
layout(): Void

Positions and sizes all child views according to the layout rules. Children are arranged sequentially along the layout axis with proper spacing and alignment. FILL children expand to use remaining space.

The layout process:

  1. Calculates space for fixed-size children
  2. Distributes remaining space among FILL children based on flex values
  3. Positions children with spacing and alignment
  4. Applies depth sorting based on childrenDepth setting

Metadata

Name Parameters
:build ceramic.macros.EntityMacro.buildForCompletion()
:autoBuild ceramic.macros.EntityMacro.buildForCompletion()
:build tracker.macros.EventsMacro.build()
:autoBuild tracker.macros.EventsMacro.build()