Xml To Compose Migration logo

Xml To Compose Migration

Community
hanamizuki
xml-to-compose-migration

Convert Android XML layouts to Jetpack Compose. Use when asked to migrate Views to Compose, convert XML to Composables, or modernize UI from View system to Compose.

Overview

Publisherhanamizuki
Repositorysolopreneur
Skill namexml-to-compose-migration
Stars
150
Forks
9
Bundled files
1
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by hanamizuki on GitHub. Read the source before you install it.

Installation

Install the Xml To Compose Migration AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/hanamizuki/solopreneur.git /tmp/solopreneur
mkdir -p .claude/skills
cp -r /tmp/solopreneur/plugins/claude/android-dev/skills/xml-to-compose-migration .claude/skills/xml-to-compose-migration
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Xml To Compose Migration in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Xml To Compose Migration on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Xml To Compose Migration is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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 LayoutCompose EquivalentNotes
LinearLayout (vertical)ColumnUse Arrangement and Alignment
LinearLayout (horizontal)RowUse Arrangement and Alignment
FrameLayoutBoxChildren stack on top of each other
ConstraintLayoutConstraintLayout (Compose)Use createRefs() and constrainAs
RelativeLayoutBox or ConstraintLayoutPrefer Box for simple overlap
ScrollViewColumn + Modifier.verticalScroll()Or use LazyColumn for lists
HorizontalScrollViewRow + Modifier.horizontalScroll()Or use LazyRow for lists
RecyclerViewLazyColumn / LazyRow / LazyGridMost common migration
ViewPager2HorizontalPagerFrom accompanist or Compose Foundation
CoordinatorLayoutCustom + ScaffoldUse TopAppBar with scroll behavior
NestedScrollViewColumn + Modifier.verticalScroll()Prefer Lazy variants

Common Widgets

XML WidgetCompose EquivalentNotes
TextViewTextUse styleTextStyle
EditTextTextField / OutlinedTextFieldRequires state hoisting
ButtonButtonUse onClick lambda
ImageViewImageUse painterResource() or Coil
ImageButtonIconButtonUse Icon inside
CheckBoxCheckboxRequires checked + onCheckedChange
RadioButtonRadioButtonUse with Row for groups
SwitchSwitchRequires state hoisting
ProgressBar (circular)CircularProgressIndicator
ProgressBar (horizontal)LinearProgressIndicator
SeekBarSliderRequires state hoisting
SpinnerDropdownMenu + ExposedDropdownMenuBoxMore complex pattern
CardViewCardFrom Material 3
ToolbarTopAppBarUse inside Scaffold
BottomNavigationViewNavigationBarMaterial 3
FloatingActionButtonFloatingActionButtonUse inside Scaffold
DividerHorizontalDivider / VerticalDivider
SpaceSpacerUse Modifier.size()

Attribute Mapping

XML AttributeCompose 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_weightModifier.weight(1f)
android:paddingModifier.padding()
android:layout_marginModifier.padding() on parent, or use Arrangement.spacedBy()
android:backgroundModifier.background()
android:visibility="gone"Conditional composition (don't emit)
android:visibility="invisible"Modifier.alpha(0f) (keeps space)
android:clickableModifier.clickable { }
android:contentDescriptionModifier.semantics { contentDescription = "" }
android:elevationModifier.shadow() or component's elevation param
android:alphaModifier.alpha()
android:rotationModifier.rotate()
android:scaleX/YModifier.scale()
android:gravityAlignment parameter or Arrangement
android:layout_gravityModifier.align()

Common Patterns

LinearLayout with Weights

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

RecyclerView to LazyColumn

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

EditText with Two-Way Binding

xml
<!-- XML with Data Binding -->
<EditText
    android:text="@={viewModel.username}"
    android:hint="@string/username_hint" />
kotlin
// 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
<!-- 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>
kotlin
// 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.linkTo(title.start)
        }
    )
}

Include / Merge → Extract Composable

xml
<!-- XML: layout_header.xml -->
<merge>
    <ImageView android:id="@+id/avatar" />
    <TextView android:id="@+id/name" />
</merge>

<!-- Usage -->
<include layout="@layout/layout_header" />
kotlin
// Compose: Extract as a reusable Composable
@Composable
fun HeaderSection(
    avatarUrl: String,
    name: String,
    modifier: Modifier = Modifier
) {
    Row(modifier = modifier) {
        AsyncImage(model = avatarUrl, contentDescription = null)
        Text(text = name)
    }
}

// Usage
HeaderSection(avatarUrl = user.avatar, name = user.name)

Incremental Migration (Interop)

Embedding Compose in XML

xml
<!-- In your XML layout -->
<androidx.compose.ui.platform.ComposeView
    android:id="@+id/compose_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
kotlin
// In Fragment/Activity
binding.composeView.setContent {
    MaterialTheme {
        MyComposable()
    }
}

Embedding XML Views in Compose

kotlin
// Use AndroidView for Views that don't have Compose equivalents
@Composable
fun MapViewComposable(modifier: Modifier = Modifier) {
    AndroidView(
        factory = { context ->
            MapView(context).apply {
                // Initialize the view
            }
        },
        update = { mapView ->
            // Update the view when state changes
        },
        modifier = modifier
    )
}

State Migration

LiveData to Compose

kotlin
// Before: Observing in Fragment
viewModel.uiState.observe(viewLifecycleOwner) { state ->
    binding.title.text = state.title
}

// After: Collecting in Compose
@Composable
fun MyScreen(viewModel: MyViewModel = hiltViewModel()) {
    val uiState by viewModel.uiState.collectAsStateWithLifecycle()
    
    Text(text = uiState.title)
}

Click Listeners

kotlin
// Before: XML + setOnClickListener
binding.submitButton.setOnClickListener {
    viewModel.submit()
}

// After: Lambda in Compose
Button(onClick = { viewModel.submit() }) {
    Text("Submit")
}

Checklist

  • All layouts converted (no include or merge left)
  • State hoisted properly (no internal mutable state for user input)
  • Click handlers converted to lambdas
  • RecyclerView adapters removed (using LazyColumn/LazyRow)
  • ViewBinding/DataBinding removed
  • Navigation integrated (NavHost or interop)
  • Theming applied (MaterialTheme)
  • Accessibility preserved (content descriptions, touch targets)
  • Preview annotations added for development
  • Old XML files deleted

References

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Xml To Compose Migration AI skill do?

Convert Android XML layouts to Jetpack Compose. Use when asked to migrate Views to Compose, convert XML to Composables, or modernize UI from View system to Compose.

Why use Xml To Compose Migration on TypingMind?

Because you install it once and use it with any model. Xml To Compose Migration is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Xml To Compose Migration in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/hanamizuki/solopreneur/tree/main/plugins/claude/android-dev/skills/xml-to-compose-migration. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Xml To Compose Migration?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Xml To Compose Migration?

As many as you like. As long as a model supports skills, you can use Xml To Compose Migration with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Xml To Compose Migration AI skill free?

Yes. It is published on GitHub by hanamizuki under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇