Suduxu
Web-Themes

XML-Themes

Build native Suduxu interfaces using XML components that map directly to Jetpack Compose.

XML Themes

XML themes define native Suduxu user interfaces using a declarative component system.

Each XML node is parsed into an internal UI tree and rendered directly into Jetpack Compose components on the device.

XML Theme
  → Parsed into UINode tree
  → Component mapping layer
  → Jetpack Compose rendering

This makes XML themes lightweight, fast, and tightly integrated with Android rendering.


Core Concept

Every XML element is treated as a UI component declaration.

Each component:

  • has a fixed name (Button, Row, Column, ...)
  • accepts a set of typed properties
  • can contain child components
  • maps 1:1 (or near 1:1) to a Compose implementation

Component System Overview

Common Structure

All components follow this structure:

  • Props (attributes) → configuration values
  • Children → nested UI nodes
  • Runtime rendering → Jetpack Compose function
<UINode>
  name: "Button"
  props: { label, onClick, ... }
  children: [...]

Components Reference

Layout Components

Column

A vertical layout container based on Column.

Properties

PropertyTypeDefaultDescription
hAlignstringcenterHorizontal alignment (start, end, center)
vArrangestringtopVertical arrangement (top, bottom, center, spaceBetween, spaceAround, spaceEvenly)
spacingnumbernullSpacing between children
backgroundstringnullBackground color
widthnumbernullFixed width
heightnumbernullFixed height
paddingnumber/objectnullPadding configuration
fillMaxSizebooleanfalseFill entire available space

Example

<Column hAlign="center" spacing="8">
    <Text text="Hello" />
    <Text text="World" />
</Column>

Row

A horizontal layout container based on Row.

Properties

PropertyTypeDefaultDescription
hArrangementstringstartHorizontal arrangement
vAlignstringcenterVertical alignment
spacingnumbernullSpacing between children
paddingnumber/objectnullPadding configuration
fillMaxSizebooleanfalseFill available space

Example

<Row hArrangement="spaceBetween" vAlign="center">
    <Text text="Left" />
    <Text text="Right" />
</Row>

UI Components

Button

A clickable UI element that triggers a callback.

Properties

PropertyTypeDefaultDescription
labelstringrequired (if no children)Button text
onClickfunctionnullClick callback
enabledbooleantrueWhether button is active
backgroundColorstringdefaultButton background
textColorstringwhiteLabel color
fontSizenumber16Text size
cornerRadiusnumber8Corner rounding
paddingnumber/objectnullInner padding

Behavior Rules

  • If children exist, they override label
  • If onClick is missing, button is inert
  • Colors accept hex or parsed color strings

Example

<Button label="Press Me" onClick="handlePress" />

Text

Displays a text label.

Properties

PropertyTypeDefaultDescription
textstringrequiredDisplayed text
colorstringblackText color
fontSizenumber16Font size
fontWeightstringnormallight, medium, bold
fontStylestringnormalitalic
textAlignstringstartstart, center, end, justify
maxLinesnumberunlimitedMax line count
softWrapbooleantrueWrapping behavior

Example

<Text text="Suduxu UI" fontWeight="bold" />

Input Components

SuduxuButton

A hardware-mapped controller button.

Properties

PropertyTypeDefaultDescription
labelstring"X"Button label
buttonInputenumAInput binding
sizenumber64Button size
onInputfunctionnullInput callback

Behavior

  • Automatically registers with KeyboardService
  • Emits ButtonInputData
  • Supports hardware mapping

Example

<SuduxuButton label="A" buttonInput="A" />

SuduxuDPad

Directional input component.

Properties

PropertyTypeDefaultDescription
sizenumber200DPad size
dPadOffsetXnumber0Horizontal offset
onInputfunctionnullDirection callback

Behavior

  • Emits ButtonInputData
  • Supports directional state transitions
  • Internally uses DPadState

Example

<SuduxuDPad size="200" />

SuduxuJoystick

Analog joystick input component.

Properties

PropertyTypeDefaultDescription
sizenumber200Joystick size
knobRatiofloat0.5Knob scaling
baseColorstringdefaultBackground color
knobColorstringdefaultKnob color
onInputfunctionnullMovement callback

Behavior

  • Emits JoyStickData
  • Provides normalized X/Y axis
  • Reports magnitude + angle

Example

<SuduxuJoystick size="200" knobRatio="0.5" />

Spacer Component

Spacer

Adds empty space in layouts.

Properties

PropertyTypeDefaultDescription
widthnumbernullHorizontal space
heightnumbernullVertical space

Example

<Spacer height="16" />

Layout Utilities

These modifiers affect all components:

Padding

padding="8"

Or directional:

padding="{ start: 8, top: 4, end: 8, bottom: 4 }"

Fill behavior

fillMaxSize="true"
fillMaxWidth="true"
fillMaxHeight="true"

Execution Model

XML → UINode tree → Renderer → Compose runtime

Key points:

  • UI is tree-based
  • Rendering is recursive
  • Props are loosely typed maps
  • Callbacks are resolved at runtime

XML themes are not validated at compile time. Invalid properties are ignored or may fail at runtime depending on parser strictness.

On this page