xml-to-compose-migration
Installation
SKILL.md
XML to Compose Migration Expert
Expert guidance for systematically migrating Android XML-based layouts and View systems to Jetpack Compose. This skill covers layout translation, state hoisting, the removal of ViewBinding/DataBinding, and incremental adoption using ComposeView and AndroidView.
Instructions
1. Layout Translation
- Map
LinearLayout(vertical/horizontal) toColumnorRow. - Map
FrameLayouttoBox. - Map
ConstraintLayout(XML) toConstraintLayout(Compose) or idiomatic nested Rows/Columns. - Replace
RecyclerViewwithLazyColumn,LazyRow, orLazyVerticalGrid. - Replace
TextView,Button,ImageViewwith their Compose equivalents (Text,Button,Image).
2. State Migration
- Replace
findViewByIdand ViewBinding references with ComposeStateorMutableState. - Convert
LiveDataorObservablesubscriptions in Fragments/Activities tocollectAsStateWithLifecycle()in Composable functions. - Hoist state to the ViewModel and use lambdas for event callbacks (e.g.,
onClicked: () -> Unit).