Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jetpack compose live preview

I just started working on jetpack compose and downloaded sample of Jetnews.

When I opened MainActivity or JetnewsApp.kt I am unable to see preview of Composable function, I added @Preview annotation as well but unable to see live preview.

Can anyone please help me to find live preview.
Thanks in advance.

like image 831
Khizar Hayat Avatar asked Oct 24 '19 09:10

Khizar Hayat


People also ask

Is jetpack compose stable?

Today, we're releasing version 1.2 of Jetpack Compose, Android's modern, native UI toolkit, continuing to build out our roadmap.

Can we use jetpack compose in existing project?

If you want to use Jetpack Compose in an existing project, you'll need to configure your project with required settings and dependencies. For more information, see Adding Jetpack Compose to your app.

Why jetpack compose is better than XML?

Compose allows you to do more with less code compared to XML. Compose is Intuitive. This means that you just need to tell Compose what you want to show the user. Compose is compatible with all your existing code: you can call Compose code from Views and Views from Compose.


1 Answers

If your Preview never show after add @Preview annotation in JetnewsApp class. In my case after adding @Preview i close project and then open project again it's working fine for me in Macbook pro.

like image 110
Anas Mehar Avatar answered Oct 20 '22 19:10

Anas Mehar