This skill helps developers transition from Android XML Views to Jetpack Compose using a structured 10-step process. It ensures a visually consistent and functionally intact migration while only handling UI migration.
$ npx skills add https://github.com/android/skills --skill migrate-xml-views-to-jetpack-composeThis skill provides a structured approach to converting Android XML-based UI layouts to Jetpack Compose. It follows a 10-step migration process designed to ensure visual consistency and preserve functionality throughout the transition. The skill focuses exclusively on UI migration, helping developers modernize their Android applications without altering business logic or non-UI components. It's grounded in Android development best practices from developer.android.com and helps LLMs assist with this specific workflow where manual migration can be error-prone.
Run the provided command to add the skill to your project.
Migrating legacy XML layouts to Jetpack Compose
Ensuring visual and functional integrity during migration
Systematic conversion for developers upgrading UI
$ npx skills add https://github.com/android/skills --skill migrate-xml-views-to-jetpack-composegit clone https://github.com/android/skillsCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Migrate the following Android XML layout files for [COMPANY]'s [PROJECT_NAME] app from XML Views to Jetpack Compose. Use the structured 10-step migration process to ensure visual consistency and functional integrity. Start with the XML file below: ```xml [XML_LAYOUT_FILE] ``` Follow these steps: 1) Analyze the XML structure, 2) Identify Compose equivalents, 3) Rewrite in Compose syntax, 4) Verify behavior, 5) Test on multiple screen sizes. Provide the final Compose code and a brief explanation of key changes.
# Migrated Jetpack Compose Layout for `activity_login.xml`
```kotlin
@Composable
fun LoginScreen() {
Column(
modifier = Modifier
.fillMaxSize()
.padding(16.dp),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
text = "Welcome to Acme Corp",
style = MaterialTheme.typography.headlineMedium,
modifier = Modifier.padding(bottom = 32.dp)
)
OutlinedTextField(
value = emailState.text,
onValueChange = { emailState.text = it },
label = { Text("Email") },
modifier = Modifier.fillMaxWidth()
)
Spacer(modifier = Modifier.height(16.dp))
OutlinedTextField(
value = passwordState.text,
onValueChange = { passwordState.text = it },
label = { Text("Password") },
visualTransformation = PasswordVisualTransformation(),
modifier = Modifier.fillMaxWidth()
)
Spacer(modifier = Modifier.height(24.dp))
Button(
onClick = { onLoginClick() },
modifier = Modifier.fillMaxWidth()
) {
Text("Sign In")
}
TextButton(onClick = { onForgotPassword() }) {
Text("Forgot Password?")
}
}
}
```
## Key Changes Made:
- Replaced `LinearLayout` with `Column` for vertical arrangement
- Converted `TextView` to `Text` with typography styling
- Transformed `EditText` into `OutlinedTextField` with state management
- Replaced `Button` with Material `Button` and `TextButton`
- Added proper padding and spacing using Compose modifiers
- Implemented state management for form fields
## Next Steps:
1. Create a state holder class for form fields
2. Implement the `onLoginClick` and `onForgotPassword` handlers
3. Add proper theming and dark mode support
4. Test on various screen sizes and orientationsTake a free 3-minute scan and get personalized AI skill recommendations.
Take free scan