Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't find where the preview window is in Android Studio 4.0(Canary)

I'm going through the tutorials about Jetpack which is ran in the Android Studio 4.0(Canary), please refer to the link post below.

https://developer.android.com/jetpack/compose/tutorial

Everything is ready except I can't find the preview window since I try to preview the "Composable" method.

Can someone give me an exact hint that where the preview window is?

like image 464
Wayne Lee Avatar asked Oct 30 '19 08:10

Wayne Lee


2 Answers

Check the official site:

Beginning with Android Studio 4.0 Canary 1, Android Studio lets you preview your composable functions within the IDE, instead of needing to download the app to an Android device or emulator. The main restriction is, the composable function must not take any parameters. Add the @Preview annotation before @Composable.

Then select on the top-right the Editor and Preview toggle.

enter image description here

enter image description here

To update the preview click the Build Refresh button.

enter image description here

like image 96
Gabriele Mariotti Avatar answered Oct 19 '22 07:10

Gabriele Mariotti


You have to build the project first (Build -> Make Project). I also had to restart Android Studio in order for previews to start working.

like image 2
Alex H Avatar answered Oct 19 '22 06:10

Alex H