Read More
Read now

Android Jetpack Compose

Save

This is time to say bye bye to layout xml. Android Jetpack Compose is toolkit to build Android App UI. You don’t need to create any xml class for UI. You need to call Jetpack Compose functions for creating Native Android App UI.

setContent block

We use ‘setContent’ block to create UI in Android Jetpack. I don’t need to create any xml class and set in Activity. We call composable methods in this block.

Composable Functions 

These functions are used to define UI functions for Android App. For creating composable functions, you need to add @Composable annotation to the function name.  Composable function can be only called by comosa

Let’s take an example :

Preview Functions

We use preview functions to check created  in Android Studio without running app again and again in device. Just like xml, in jetpack we can create our layout preview. For this, we need to create Preview function of our composable function. Add preview in the prefix of function name and all our composable function inside this preview method. Also, we need to add @Preview & @Composable annotation.

Let’s take an example :

If there is any error in your code, it will not create preview & show you error as well.

NOTE : We need alteast Android Studio version 4.0 for preview functions. You can download latest Android Studio version from below link :

Current canary build of Android Studio

This is basic introduction of Android Jetpack.

Hope, this blog is helpful for you.

 

 

 

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!

Deniel Kerr

Owner and Founder. Opencart

Talk to Sales
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home