Previewing Your UI
Use @Preview to iterate fast.
Why Previews Help
Building and running an app on a device takes time. Compose offers a faster way to see your UI: the preview.
A preview renders a composable right inside Android Studio, so you can check your layout without launching the full app on an emulator or phone.
The @Preview Annotation
To preview a composable, you create a separate function and mark it with @Preview. Android Studio then shows its rendered output in the design pane.
The preview function itself is also a composable, so it carries both @Preview and @Composable.
@Preview
@Composable
fun GreetingPreview() {
Greeting("World")
}All lessons in this course
- What a Composable Is
- Text and Column Basics
- Previewing Your UI
- Building a Profile Card