Awesome-omni-skill xml-to-compose
Convert Android XML layouts to Jetpack Compose. Use when asked to migrate XML layouts, convert views to composables, or help with Compose migration. Handles layouts, widgets, attributes, styles, and resource references.
install
source · Clone the upstream repo
git clone https://github.com/diegosouzapw/awesome-omni-skill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/diegosouzapw/awesome-omni-skill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data-ai/xml-to-compose-majiayu000" ~/.claude/skills/diegosouzapw-awesome-omni-skill-xml-to-compose && rm -rf "$T"
manifest:
skills/data-ai/xml-to-compose-majiayu000/SKILL.mdsource content
XML to Jetpack Compose Converter
Convert Android XML layouts to idiomatic Jetpack Compose code.
Conversion Process
- Analyze the XML structure and identify root layout
- Map each view to its Compose equivalent
- Convert attributes to Modifier chains (order matters!)
- Handle resource references (@string, @dimen, @color)
- Extract styles into reusable composables or theme values
Quick Reference
Layouts
| XML | Compose |
|---|---|
| |
| |
| |
| / or (dependency) |
| + |
| / |
| |
Common Widgets
| XML | Compose |
|---|---|
| |
| / |
| |
| / (Coil) |
| |
| |
| / |
| |
Modifier Order
Order matters! Follow this sequence:
/clickabletoggleable
(outer)padding
/size
/fillMaxWidthweight
/backgroundclipborder
(inner)padding
Detailed Mappings
See reference files for complete mappings:
— Layout containersreferences/layouts.md
— UI componentsreferences/widgets.md
— XML attributes to Modifiersreferences/attributes.md
Output Guidelines
- Use Material 3 — Import from
androidx.compose.material3 - Prefer built-in modifiers — Avoid custom implementations
- Handle nullability — XML allows null text, Compose needs defaults
- Extract dimensions — Use
or define in themedimensionResource() - Keep composables stateless — Hoist state to caller
- Add Preview — Include
function for each composable@Preview
Example
Input:
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="16dp"> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/welcome" android:textSize="24sp" android:textStyle="bold"/> <Button android:id="@+id/action_button" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:text="@string/get_started"/> </LinearLayout>
Output:
@Composable fun WelcomeSection( onGetStartedClick: () -> Unit, modifier: Modifier = Modifier ) { Column( modifier = modifier .fillMaxWidth() .padding(16.dp) ) { Text( text = stringResource(R.string.welcome), fontSize = 24.sp, fontWeight = FontWeight.Bold ) Spacer(modifier = Modifier.height(8.dp)) Button( onClick = onGetStartedClick, modifier = Modifier.fillMaxWidth() ) { Text(text = stringResource(R.string.get_started)) } } } @Preview(showBackground = true) @Composable private fun WelcomeSectionPreview() { WelcomeSection(onGetStartedClick = {}) }
Key conversions:
→match_parent
/fillMaxWidth()fillMaxHeight()
→ default (no modifier needed)wrap_content
→layout_marginTop
between elementsSpacer- Click listeners → lambda parameters
- IDs → not needed (state hoisting instead)