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.
Best use case
xml-to-compose is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
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.
Teams using xml-to-compose should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/xml-to-compose/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How xml-to-compose Compares
| Feature / Agent | xml-to-compose | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
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.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# XML to Jetpack Compose Converter
Convert Android XML layouts to idiomatic Jetpack Compose code.
## Conversion Process
1. Analyze the XML structure and identify root layout
2. Map each view to its Compose equivalent
3. Convert attributes to Modifier chains (order matters!)
4. Handle resource references (@string, @dimen, @color)
5. Extract styles into reusable composables or theme values
## Quick Reference
### Layouts
| XML | Compose |
|-----|---------|
| `LinearLayout (vertical)` | `Column` |
| `LinearLayout (horizontal)` | `Row` |
| `FrameLayout` | `Box` |
| `ConstraintLayout` | `Column`/`Row` or `ConstraintLayout` (dependency) |
| `ScrollView` | `Column` + `Modifier.verticalScroll()` |
| `RecyclerView` | `LazyColumn` / `LazyRow` |
| `ViewPager2` | `HorizontalPager` |
### Common Widgets
| XML | Compose |
|-----|---------|
| `TextView` | `Text` |
| `EditText` | `TextField` / `OutlinedTextField` |
| `Button` | `Button` |
| `ImageView` | `Image` / `AsyncImage` (Coil) |
| `CheckBox` | `Checkbox` |
| `Switch` | `Switch` |
| `ProgressBar` | `CircularProgressIndicator` / `LinearProgressIndicator` |
| `CardView` | `Card` |
### Modifier Order
Order matters! Follow this sequence:
1. `clickable` / `toggleable`
2. `padding` (outer)
3. `size` / `fillMaxWidth` / `weight`
4. `background` / `clip`
5. `border`
6. `padding` (inner)
## Detailed Mappings
See reference files for complete mappings:
- `references/layouts.md` — Layout containers
- `references/widgets.md` — UI components
- `references/attributes.md` — XML attributes to Modifiers
## Output Guidelines
1. **Use Material 3** — Import from `androidx.compose.material3`
2. **Prefer built-in modifiers** — Avoid custom implementations
3. **Handle nullability** — XML allows null text, Compose needs defaults
4. **Extract dimensions** — Use `dimensionResource()` or define in theme
5. **Keep composables stateless** — Hoist state to caller
6. **Add Preview** — Include `@Preview` function for each composable
## Example
Input:
```xml
<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:
```kotlin
@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()`
- `wrap_content` → default (no modifier needed)
- `layout_marginTop` → `Spacer` between elements
- Click listeners → lambda parameters
- IDs → not needed (state hoisting instead)Related Skills
compose-ui-control
Control a running Compose Desktop application via HTTP. Use when you need to interact with UI elements, click buttons, enter text, wait for elements to appear, or capture screenshots in a Compose Desktop app that has compose-ui-test-server enabled.
android-ui-compose
This skill is used to implement Android UI in Jetpack Compose based on an existing UX flow, focusing on clear hierarchy, list vs form separation and discoverable navigation.
android-jetpack-compose-expert
Expert guidance for building modern Android UIs with Jetpack Compose, covering state management, navigation, performance, and Material Design 3.
workflow-composer
Chain multiple skills together into automated workflows with conditional logic and parallel execution
composer-dependency-management
Rules pertaining to Composer dependency management, promoting best practices for declaring and updating dependencies.
bgo
Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.
ui-ux-pro-max
UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 9 stacks.
ui-ux-principles
Apply core UI/UX design principles for intuitive, beautiful interfaces. Covers visual hierarchy, color theory, typography, spacing systems, Gestalt principles, usability heuristics, and user-centered design. Use for design decisions, layout planning, and creating polished user experiences.
UI/UX Intelligence Expert
UI/UX 设计智能库与推荐专家。包含 67 种风格、96 种配色方案、57 种字体搭配、99 条 UX 指南,支持跨技术栈的设计系统生成。
ui ux
Searchable database of UI styles, color palettes, font pairings, chart types, product recommendations, UX guidelines, and stack-specific best practices.
ui-ux-improve
Research UI/UX improvements with trend analysis and generate actionable recommendations. Use when you need comprehensive UI/UX analysis and improvement suggestions.
ui-ux-designer
Create interface designs, wireframes, and design systems. Masters user research, accessibility standards, and modern design tools.