Jetpack Compose is due for production-ready in July. Which make is a go-to UI Framework.
In this article we are going to learn how to create reusable Custom Views that can be shared and re-used within your own project or with the Android Community.
Brief Composable introduction
This will be a short and if you have any experience with Composable, you can skip this section.
@Composable
fun MyView() {
Text("Hello World")
}@Composable
This is an annotation for the compiler treat the code in a particular way. Compose only work with Kotlin because it relies on Kotlin Compiler for some operations.
fun MyView()
Composable are functions, that mean they can be declared directly in a plain kotlin file, in class or even in companion objects.
{
Text("Hello World")
}
This is a body of the function, containing all the rendering you wish to do.
Understanding Modifier
The Modifier is a common parameter on all Views, Text, Row, Column, Image… It allows developers to set many kind of properties, such as padding, height, width, clickable…