xml-to-compose-migration

new-silvermoon/awesome-android-agent-skills · updated Apr 8, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills add https://github.com/new-silvermoon/awesome-android-agent-skills --skill xml-to-compose-migration
0 commentsdiscussion
summary

Systematically convert Android XML layouts to idiomatic Jetpack Compose, preserving functionality while embracing Compose patterns. This skill covers layout mapping, state migration, and incremental adoption strategies.

skill.md

XML to Compose Migration

Overview

Systematically convert Android XML layouts to idiomatic Jetpack Compose, preserving functionality while embracing Compose patterns. This skill covers layout mapping, state migration, and incremental adoption strategies.

Workflow

1. Analyze the XML Layout

  • Identify the root layout type (ConstraintLayout, LinearLayout, FrameLayout, etc.).
  • List all View widgets and their key attributes.
  • Map data binding expressions (@{}) or view binding references.
  • Identify custom views that need special handling.
  • Note any include, merge, or ViewStub usage.

2. Plan the Migration

  • Decide: Full rewrite or incremental migration (using ComposeView/AndroidView).
  • Identify state sources (ViewModel, LiveData, savedInstanceState).
  • List reusable components to extract as separate Composables.
  • Plan navigation integration if using Navigation component.

3. Convert Layouts

Apply the layout mapping table below to convert each View to its Compose equivalent.

4. Migrate State

  • Convert LiveData observation to StateFlow collection or observeAsState().
  • Replace findViewById / ViewBinding with Compose state.
  • Convert click listeners to lambda parameters.

5. Test and Verify

  • Compare visual output between XML and Compose versions.
  • Test accessibility (content descriptions, touch targets).
  • Verify state preservation across configuration changes.

Layout Mapping Reference

Container Layouts

XML Layout Compose Equivalent Notes
LinearLayout (vertical) Column Use Arrangement and Alignment
LinearLayout (horizontal) Row Use Arrangement and Alignment
FrameLayout Box Children stack on top of each other
ConstraintLayout ConstraintLayout (Compose) Use createRefs() and constrainAs
RelativeLayout Box or ConstraintLayout Prefer Box for simple overlap
ScrollView Column + Modifier.verticalScroll() Or use LazyColumn for lists
HorizontalScrollView Row + Modifier.horizontalScroll() Or use LazyRow for lists
RecyclerView LazyColumn / LazyRow / LazyGrid Most common migration
ViewPager2 HorizontalPager From accompanist or Compose Foundation
CoordinatorLayout Custom + Scaffold Use TopAppBar with scroll behavior
NestedScrollView Column + Modifier.verticalScroll() Prefer Lazy variants

Common Widgets

XML Widget Compose Equivalent Notes
TextView Text Use styleTextStyle
EditText TextField / OutlinedTextField Requires state hoisting
Button Button Use onClick lambda
ImageView Image Use painterResource() or Coil
ImageButton IconButton Use Icon inside
CheckBox Checkbox Requires checked + onCheckedChange
RadioButton RadioButton Use with Row for groups
Switch Switch Requires state hoisting
ProgressBar (circular) CircularProgressIndicator
ProgressBar (horizontal) LinearProgressIndicator
SeekBar Slider Requires state hoisting
Spinner DropdownMenu + ExposedDropdownMenuBox More complex pattern
CardView Card From Material 3
Toolbar TopAppBar Use inside Scaffold
BottomNavigationView NavigationBar Material 3
FloatingActionButton FloatingActionButton Use inside Scaffold
Divider HorizontalDivider / VerticalDivider
Space Spacer Use Modifier.size()

Attribute Mapping

XML Attribute Compose Modifier/Property
android:layout_width="match_parent" Modifier.fillMaxWidth()
android:layout_height="match_parent" Modifier.fillMaxHeight()
android:layout_width="wrap_content" Modifier.wrapContentWidth() (usually implicit)
android:layout_weight Modifier.weight(1f)
android:padding Modifier.padding()
android:layout_margin Modifier.padding() on parent, or use Arrangement.spacedBy()
android:background Modifier.background()
android:visibility="gone" Conditional composition (don't emit)
android:visibility="invisible" Modifier.alpha(0f) (keeps space)
android:clickable Modifier.clickable { }
android:contentDescription Modifier.semantics { contentDescription = "" }
android:elevation Modifier.shadow() or component's elevation param
android:alpha Modifier.alpha()
android:rotation Modifier.rotate()
android:scaleX/Y Modifier.scale()
android:gravity Alignment parameter or Arrangement
android:layout_gravity Modifier.align()

Common Patterns

LinearLayout with Weights

<!-- XML -->
<LinearLayout android:orientation="horizontal">
    <View android:layout_weight="1" />
    <View android:layout_weight="2" />
</LinearLayout>
// Compose
Row(modifier = Modifier.fillMaxWidth()) {
    Box(modifier = Modifier.weight(1f))
    Box(modifier = Modifier.weight(2f))
}

RecyclerView to LazyColumn

<!-- XML -->
<androidx.recyclerview.widget.RecyclerView
    android:id="@+id/recyclerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
// Compose
LazyColumn(modifier = Modifier.fillMaxSize()) {
    items(items, key = { it.id }) { item ->
        ItemRow(item = item, onClick = { onItemClick(item) })
    }
}

EditText with Two-Way Binding

<!-- XML with Data Binding -->
<EditText
    android:text="@={viewModel.username}"
    android:hint="@string/username_hint" />
// Compose
val username by viewModel.username.collectAsState()

OutlinedTextField(
    value = username,
    onValueChange = { viewModel.updateUsername(it) },
    label = { Text(stringResource(R.string.username_hint)) },
    modifier = Modifier.fillMaxWidth()
)

ConstraintLayout Migration

<!-- XML -->
<androidx.constraintlayout.widget.ConstraintLayout>
    <TextView
        android:id="@+id/title"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent" />
    <TextView
        android:id="@+id/subtitle"
        app:layout_constraintTop_toBottomOf="@id/title"
        app:layout_constraintStart_toStartOf="@id/title" />
</androidx.constraintlayout.widget.ConstraintLayout>
// Compose
ConstraintLayout(modifier = Modifier.fillMaxWidth()) {
    val (title, subtitle) = createRefs()
    
    Text(
        text = "Title",
        modifier = Modifier.constrainAs(title) {
            top.linkTo(parent.top)
            start.linkTo(parent.start)
        }
    )
    Text(
        text = "Subtitle", 
        modifier = Modifier.constrainAs(subtitle) {
            top.linkTo(title.bottom)
            start.
how to use xml-to-compose-migration

How to use xml-to-compose-migration on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add xml-to-compose-migration
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills add https://github.com/new-silvermoon/awesome-android-agent-skills --skill xml-to-compose-migration

The skills CLI fetches xml-to-compose-migration from GitHub repository new-silvermoon/awesome-android-agent-skills and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/xml-to-compose-migration

Reload or restart Cursor to activate xml-to-compose-migration. Access the skill through slash commands (e.g., /xml-to-compose-migration) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

Task Automation & Efficiency

Automate repetitive workflows and reduce manual effort

Example

Generate reports, summarize documents, draft communications

Save 3-5 hours per week on routine tasks

Knowledge Enhancement

Learn new skills, understand complex topics, get expert guidance

Example

Explain concepts, provide examples, suggest learning resources

Accelerate learning and skill development by 2x

Quality Improvement

Enhance output quality through reviews, suggestions, and refinements

Example

Review drafts, suggest improvements, catch errors

Improve work quality by 30-40% with less effort

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client with skill support
  • Clear understanding of task or problem to solve
  • Willingness to iterate and refine outputs

Time Estimate

15-45 minutes depending on use case complexity

Installation Steps

  1. 1.Install skill using provided installation command
  2. 2.Test with simple use case relevant to your work
  3. 3.Evaluate output quality and relevance
  4. 4.Iterate on prompts to improve results
  5. 5.Integrate into regular workflow if valuable

Common Pitfalls

  • Expecting perfect results without iteration
  • Not providing enough context in prompts
  • Using skill for tasks outside its intended scope
  • Accepting outputs without review and validation

Best Practices

✓ Do

  • +Start with clear, specific prompts
  • +Provide relevant context and constraints
  • +Review and refine all outputs before using
  • +Iterate to improve output quality
  • +Document successful prompt patterns

✗ Don't

  • Don't use without understanding skill limitations
  • Don't skip validation of outputs
  • Don't share sensitive information in prompts
  • Don't expect skill to replace human judgment

💡 Pro Tips

  • Be specific about desired format and style
  • Ask for multiple options to choose from
  • Request explanations to understand reasoning
  • Combine AI efficiency with human expertise

When to Use This

✓ Use When

Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.

✗ Avoid When

Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.

Learning Path

  1. 1Familiarize yourself with skill capabilities and limitations
  2. 2Start with low-risk, non-critical tasks
  3. 3Progress to more complex and valuable use cases
  4. 4Build expertise through regular use and experimentation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.568 reviews
  • Li Kapoor· Dec 28, 2024

    xml-to-compose-migration is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Carlos Abebe· Dec 24, 2024

    Solid pick for teams standardizing on skills: xml-to-compose-migration is focused, and the summary matches what you get after install.

  • Camila Farah· Dec 20, 2024

    Useful defaults in xml-to-compose-migration — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Min Flores· Dec 20, 2024

    Registry listing for xml-to-compose-migration matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Diya Gonzalez· Dec 12, 2024

    xml-to-compose-migration has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Sakura Iyer· Nov 19, 2024

    Keeps context tight: xml-to-compose-migration is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Carlos Choi· Nov 15, 2024

    I recommend xml-to-compose-migration for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Luis Yang· Nov 11, 2024

    We added xml-to-compose-migration from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Luis Liu· Nov 11, 2024

    xml-to-compose-migration reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Sakura Menon· Oct 10, 2024

    I recommend xml-to-compose-migration for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

showing 1-10 of 68

1 / 7