Tarsila Costalonga
Tarsila Costalonga

Reputation: 1104

Center and Start text in jetpack compose

How can I put the text in the center of the total clickable area and still in the start of the component?

Like an android:layout_gravity="center" with margin.

enter image description here

Upvotes: 1

Views: 651

Answers (1)

Thracian
Thracian

Reputation: 67423

You can use contentAlignment = Alignment.CenterStart with Box.

Box(
    modifier = Modifier
        .clickable {
            
        }
        .fillMaxWidth()
        .height(46.dp),
    contentAlignment = Alignment.CenterStart
) {
    Text("Hello World")
}

Upvotes: 3

Related Questions