What Is Jetpack Compose?
Understand declarative UI in Android.
What Is Jetpack Compose?
Jetpack Compose is Android's modern toolkit for building native UI. Instead of writing XML layout files, you describe your UI directly in Kotlin code.
Compose is declarative: you tell it what the screen should look like for a given state, and it figures out how to draw and update it.
The Old Way: XML Views
Traditionally, an Android screen needed two parts:
- An XML layout file describing the widgets.
- Kotlin/Java code that finds those views with
findViewByIdand mutates them.
Keeping the XML and the code in sync was tedious and error-prone.
<!-- res/layout/activity_main.xml -->
<TextView
android:id="@+id/greeting"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />All lessons in this course
- What Is Jetpack Compose?
- Your First Composable
- Text, Image, and Button
- Previews and Hot Reload