Roaming about Jetpack Compose Part 2

Tram Ho

Part II : Learning Jetpack Compose

In this article, I will demonstrate the basics of Jetpack Compose. You will learn how to write composable functions, the building blocks that you use to create beautiful user interfaces with Jetpack Compose. Then you’ll see how to implement the most common functions like text, image, or button elements.

Composable functions

You need to annotate a function or expression with Composable – a special annotation class. Any function annotated in this way is also called a composable function. Annotated classes simplify code by attaching metadata to it. Javac, the java compiler, uses the annotation processing engine to scan and process comments at compile time. Here we learn about popular composers.

Text

This is a screen without text view

TextView is implemented as follows

Basically, a Text Compose has the same properties as TextView in Android

Programming the interface is indispensable with the preview tool, and it is already built into Android Studio, you just need to add the Preview  tag to it.

Buttons

Available API’s help you create a Button quickly

Examples are as follows:

And we have the result:

AlertDialog

We have the following demo:

And this is the result :

Conclude

Basically, in this article, I only briefly introduce you to the basic Compose. And as an Android programmer, you can completely read and understand the above code. In the next post, I will introduce you more about the ViewGroup build in Jetpack Compose.

Share the news now