0Pricing
Android Academy · Lesson

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

  1. What a Composable Is
  2. Text and Column Basics
  3. Previewing Your UI
  4. Building a Profile Card
← Back to Android Academy