Documentation Index
Fetch the complete documentation index at: https://mintlify.com/new-silvermoon/awesome-android-agent-skills/llms.txt
Use this file to discover all available pages before exploring further.
What This Skill Provides
The XML to Compose Migration skill helps you systematically convert Android XML layouts to Jetpack Compose while preserving functionality and embracing modern Compose patterns. This includes layout mapping, state migration, and incremental adoption strategies.When to Use This Skill
- Migrating existing XML-based UI to Compose
- Converting Views to Composables
- Modernizing legacy Android UI code
- Planning incremental Compose adoption
- Understanding View-to-Compose equivalents
Migration 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, orViewStubusage
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 layout mappings to convert each View to its Compose equivalent.4. Migrate State
- Convert
LiveDataobservation toStateFlowcollection orobserveAsState() - 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
- LinearLayout
- FrameLayout
- RecyclerView
XML
Compose
Common Widgets
- TextView
- EditText
- ImageView
XML
Compose
Quick Reference Table
| XML Widget | Compose Equivalent | Notes |
|---|---|---|
TextView | Text | Use style parameter |
EditText | TextField / OutlinedTextField | Requires state hoisting |
Button | Button | Use onClick lambda |
ImageView | Image | Use painterResource() or Coil |
CheckBox | Checkbox | Requires state hoisting |
Switch | Switch | Requires state hoisting |
ProgressBar | CircularProgressIndicator | For circular variant |
RecyclerView | LazyColumn / LazyRow | Most common migration |
CardView | Card | Material 3 component |
Toolbar | TopAppBar | Use inside Scaffold |
Attribute Mapping
Layout Attributes
Visual Attributes
| XML Attribute | Compose Modifier |
|---|---|
android:padding | Modifier.padding() |
android:layout_margin | Modifier.padding() on parent |
android:background | Modifier.background() |
android:visibility="gone" | Conditional composition |
android:visibility="invisible" | Modifier.alpha(0f) |
android:clickable | Modifier.clickable { } |
android:elevation | Modifier.shadow() |
android:alpha | Modifier.alpha() |
android:rotation | Modifier.rotate() |
Common Migration Patterns
LinearLayout with Weights
RecyclerView to LazyColumn
EditText with Two-Way Binding
ConstraintLayout Migration
For simple vertical/horizontal layouts, prefer
Column/Row over ConstraintLayout in Compose for better performance.Include / Merge to Composable
Incremental Migration (Interop)
Embedding Compose in XML
Embedding XML Views in Compose
AndroidView Wrapper
Use
AndroidView for Views that don’t have Compose equivalents yet, such as MapView, WebView, or custom third-party views.State Migration
LiveData to StateFlow
Click Listeners to Lambdas
Migration Checklist
- All layouts converted (no
includeormergeleft) - 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
Related Skills
- Compose UI - Learn Compose best practices
- Compose Navigation - Migrate navigation to Compose
- Coil Compose - Load images in Compose
