Creating a button in Jetpack Compose
We must note that we cannot cover all views in just one recipe; we have a chapter dedicated to learning more about Jetpack Compose, so in the project we have created, we will just try to create two more additional views for our project.
Getting ready
Open the Android Community project, as that is the project we will be building upon in this recipe.
How to do it…
Let’s start by implementing a simple button in Compose:
- Let’s go ahead and organize our code and align the text to the center by adding a
Column()
to organize our views. This should be added to thesetContent{}
function:Column(
modifier = Modifier
.fillMaxSize()
.wrapContentSize(Alignment.Center),
horizontalAlignment = Alignment.CenterHorizontally
) {
Greeting("Hello, Android Community...