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.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "xml-to-compose" with this command: npx skills add singhsume123/xml-to-compose-skill/singhsume123-xml-to-compose-skill-xml-to-compose

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

XMLCompose
LinearLayout (vertical)Column
LinearLayout (horizontal)Row
FrameLayoutBox
ConstraintLayoutColumn/Row or ConstraintLayout (dependency)
ScrollViewColumn + Modifier.verticalScroll()
RecyclerViewLazyColumn / LazyRow
ViewPager2HorizontalPager

Common Widgets

XMLCompose
TextViewText
EditTextTextField / OutlinedTextField
ButtonButton
ImageViewImage / AsyncImage (Coil)
CheckBoxCheckbox
SwitchSwitch
ProgressBarCircularProgressIndicator / LinearProgressIndicator
CardViewCard

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:

<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_parentfillMaxWidth() / fillMaxHeight()
  • wrap_content → default (no modifier needed)
  • layout_marginTopSpacer between elements
  • Click listeners → lambda parameters
  • IDs → not needed (state hoisting instead)

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

test_skill

import json import tkinter as tk from tkinter import messagebox, simpledialog

Archived SourceRecently Updated
General

neo

Browse websites, read web pages, interact with web apps, call website APIs, and automate web tasks. Use Neo when: user asks to check a website, read a web page, post on social media (Twitter/X), interact with any web app, look up information on a specific site, scrape data from websites, automate browser tasks, or when you need to call any website's API. Keywords: website, web page, browse, URL, http, API, twitter, tweet, post, scrape, web app, open site, check site, read page, social media, online service.

Archived SourceRecently Updated
General

image-gen

Generate AI images from text prompts. Triggers on: "生成图片", "画一张", "AI图", "generate image", "配图", "create picture", "draw", "visualize", "generate an image".

Archived SourceRecently Updated
General

explainer

Create explainer videos with narration and AI-generated visuals. Triggers on: "解说视频", "explainer video", "explain this as a video", "tutorial video", "introduce X (video)", "解释一下XX(视频形式)".

Archived SourceRecently Updated