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 renderingThis 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
| Property | Type | Default | Description |
|---|---|---|---|
hAlign | string | center | Horizontal alignment (start, end, center) |
vArrange | string | top | Vertical arrangement (top, bottom, center, spaceBetween, spaceAround, spaceEvenly) |
spacing | number | null | Spacing between children |
background | string | null | Background color |
width | number | null | Fixed width |
height | number | null | Fixed height |
padding | number/object | null | Padding configuration |
fillMaxSize | boolean | false | Fill 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
| Property | Type | Default | Description |
|---|---|---|---|
hArrangement | string | start | Horizontal arrangement |
vAlign | string | center | Vertical alignment |
spacing | number | null | Spacing between children |
padding | number/object | null | Padding configuration |
fillMaxSize | boolean | false | Fill available space |
Example
<Row hArrangement="spaceBetween" vAlign="center">
<Text text="Left" />
<Text text="Right" />
</Row>UI Components
Text
Displays a text label.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
text | string | required | Displayed text |
color | string | black | Text color |
fontSize | number | 16 | Font size |
fontWeight | string | normal | light, medium, bold |
fontStyle | string | normal | italic |
textAlign | string | start | start, center, end, justify |
maxLines | number | unlimited | Max line count |
softWrap | boolean | true | Wrapping behavior |
Example
<Text text="Suduxu UI" fontWeight="bold" />Input Components
SuduxuDPad
Directional input component.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
size | number | 200 | DPad size |
dPadOffsetX | number | 0 | Horizontal offset |
onInput | function | null | Direction callback |
Behavior
- Emits
ButtonInputData - Supports directional state transitions
- Internally uses
DPadState
Example
<SuduxuDPad size="200" />SuduxuJoystick
Analog joystick input component.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
size | number | 200 | Joystick size |
knobRatio | float | 0.5 | Knob scaling |
baseColor | string | default | Background color |
knobColor | string | default | Knob color |
onInput | function | null | Movement 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
| Property | Type | Default | Description |
|---|---|---|---|
width | number | null | Horizontal space |
height | number | null | Vertical 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 runtimeKey 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.