AI for Compose

Use Gemini in Android Studio to empower faster, better development with Jetpack Compose.

Compose preview generation with Gemini

Compose previews are a powerful tool for visualizing composables at design time in Android Studio, but manually setting up mock data for the preview parameters can be time-consuming. Gemini in Android Studio includes a feature that solves this problem: automated Compose preview generation.

You can access this tool in two ways:

  • Context menu. Within any composable, right-click and navigate to Gemini > Generate Compose Preview or Generate Compose Preview for this file.

Compose preview generation from context menu

  • Empty preview panel. Click the provided link in an empty preview panel.

Compose preview generation from preview panel

The feature presents a diff view with Gemini's suggested Compose preview code. You can accept the changes as is, make edits, or reject the suggestions altogether. While Gemini's code might not be perfect every time, it should provide a valuable starting point to accelerate your development workflow.