Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 22.214.171.124 release ready!
Updated 29 November 2019
Jetpack Compose is a modern toolkit for building native Android UI. It’s based on the declarative programming model, so you can simply describe what your UI should look like, and Compose takes care of the rest—as app state changes, your UI automatically updates.
This feature is currently in alpha version but we really need to think about it this early.
Jetpack compose is currently present in Android Studio 4.0 and above which is in the canary build which means currently there might be some bugs in it and shouldn’t be used in the production version of the apps.
You need to set your app’s minimum API level to 21 or higher and enable Jetpack Compose in your app’s build.gradlefile, as shown below:
Jetpack Compose currently requires an experimental version of the Kotlin-Gradle plugin. To include this plugin in your app, include the following dependencies in your project’s build.gradle file:
Include Jetpack Compose toolkit dependencies in your app’s build.gradle file, as shown below:
Let’s take a look at the code needed for a simple “Hello World” app with Jetpack Compose.
In the onCreate method we set the content of our Compose app by calling setContent. This is a method that initializes the composable widget tree and wraps it in a FrameLayout.
To make things work we need to wrap our app in a CraneWrapper and MaterialTheme. CraneWrapper is responsible for setting up providers for the Context, FocusManager and TextInputService. The MaterialTheme is needed to provide colors, styles, and fonts to your widgets. With this in place, we can add a Textcomponent that will render our text on the screen in a certain style.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.