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.
npx skills add https://github.com/new-silvermoon/awesome-android-agent-skills --skill xml-to-compose-migration
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.
ConstraintLayout, LinearLayout, FrameLayout, etc.).@{}) or view binding references.include, merge, or ViewStub usage.ComposeView/AndroidView).Apply the layout mapping table below to convert each View to its Compose equivalent.
LiveData observation to StateFlow collection or observeAsState().findViewById / ViewBinding with Compose state.| 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 |
| XML Widget | Compose Equivalent | Notes |
|------------|-------------------|-------|
| TextView | Text | Use style → TextStyle |
| 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() |
| 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() |
<!-- 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))
}
<!-- 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) })
}
}
<!-- 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()
)
<!-- 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.linkTo(title.start)
}
)
}
<!-- XML: layout_header.xml -->
<merge>
<ImageView android:id="@+id/avatar" />
<TextView android:id="@+id/name" />
</merge>
<!-- Usage -->
<include layout="@layout/layout_header" />
// 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)
<!-- In your XML layout -->
<androidx.compose.ui.platform.ComposeView
android:id="@+id/compose_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
// In Fragment/Activity
binding.composeView.setContent {
MaterialTheme {
MyComposable()
}
}
// 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
)
}
// 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)
}
// Before: XML + setOnClickListener
binding.submitButton.setOnClickListener {
viewModel.submit()
}
// After: Lambda in Compose
Button(onClick = { viewModel.submit() }) {
Text("Submit")
}
include or merge left)Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use for complex artifacts requiring state management, routing, or shadcn/ui components - not for simple single-file HTML/JSX artifacts.
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use for complex artifacts requiring state management, routing, or shadcn/ui components - not for simple single-file HTML/JSX artifacts.
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.
Set up Tailwind CSS v4 in Expo with react-native-css and NativeWind v5 for universal styling
Use Expo DOM components to run web code in a webview on native and as-is on web. Migrate web code to native incrementally.
Take new-silvermoon/xml-to-compose-migration from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.