Jetpack Compose is Android's modern toolkit for building native user interfaces with Kotlin functions instead of XML layout files. You describe what the screen should look like for the current state, and Compose updates the screen when that state changes. XML layouts, by contrast, define a tree of View objects that you find and modify imperatively from code.
Google recommends Compose for new Android UI, and it is stable and widely used in production. The older View system still works and many apps mix both.
Compose is a declarative UI framework. A screen is built from composable functions, which are ordinary Kotlin functions annotated with @Composable. They take data as parameters and emit UI. There is no separate layout language, no findViewById() and no view binding.
It ships as a set of AndroidX libraries, with a Kotlin compiler plugin that transforms composable functions. Because the UI is code, you can use loops, conditions and normal Kotlin abstractions to build it.
With XML views you inflate a layout and then mutate the views when data changes. With Compose you rebuild the description from state, and the runtime applies only the differences.
A counter with XML needs a layout file and activity code:
The same counter in Compose is one function:
When count changes, Compose recomposes only the parts of the UI that read it. You never update the Text by hand, so the screen cannot drift out of sync with the state.
| Topic | XML Views | Jetpack Compose |
|---|---|---|
| Language | XML plus Kotlin or Java | Kotlin only |
| Style | Imperative, mutate views | Declarative, describe state |
| Layouts | LinearLayout, ConstraintLayout | Column, Row, Box, LazyColumn |
| Lists | RecyclerView plus adapter | LazyColumn with items |
| Theming | Styles and themes XML | MaterialTheme in code |
| Previews | Layout editor | @Preview functions |
| Reuse | Custom views, includes | Plain composable functions |
State in Compose is held in objects such as MutableState. When a composable reads a state value, Compose records the dependency, and a change to the value schedules recomposition of that composable. remember keeps a value across recompositions, and rememberSaveable also survives configuration changes and process death for simple data.
For screen-level state you normally keep it in a ViewModel and expose it as a StateFlow, then collect it with collectAsStateWithLifecycle(). This is the same architecture advice as with Views.
You do not have to rewrite an app at once. Interoperability goes both ways:
ComposeView to an XML layout, and call setContent on it.AndroidView.This lets you migrate screen by screen, starting with new features.
Choose Compose for new apps and new screens. It usually means less boilerplate, easier theming and previews, and simpler animation. Keep Views where a large, stable screen works well, or where a third-party library offers only a View-based component. Check the minimum SDK of your libraries, since Compose supports API 21 and higher at the time of writing.
Not automatically. Performance depends on how you write it, such as stable parameters and lazy lists. Compose can be as fast as Views when used well, and release builds with R8 matter a lot.
For existing apps, yes. Many codebases still contain XML layouts, and some system resources such as the manifest and drawables remain XML.
Yes, Compose requires Kotlin. Java code can live in the same app but cannot define composables.
Compose Multiplatform from JetBrains extends the same model to desktop, iOS and web, but Jetpack Compose itself is the Android toolkit.
Jetpack Compose builds UI declaratively with composable Kotlin functions that react to state, while XML views are inflated and updated imperatively. Compose reduces boilerplate and keeps UI in sync with state, and it can be mixed with Views during migration. Use it for new screens, and move old ones when it is worthwhile.