Androidew1267
Androidew1267

Reputation: 623

How to make Row component whole clickable with padding?

I have a Row component which is not clickable on its whole area because of padding modifier. How can I make this component clickable on whole area with the same padding effect?

@Composable
fun UserRow() {
        Row(
            verticalAlignment = Alignment.CenterVertically,
            modifier = Modifier
                .fillMaxWidth()
                .padding(16.dp)
                .clickable {
                    /* ... */
                }
        ) {
            Icon(
                /* ... */
            )
            Text(
                /* ... */
            )
        }
    }
}

Upvotes: 12

Views: 3961

Answers (1)

Tonnie
Tonnie

Reputation: 8122

The padding modifier should be the last as shown below.

Row(
    verticalAlignment = Alignment.CenterVertically,
    modifier = Modifier
        .fillMaxWidth()
        .clickable {
            /* ... */
        }
        .padding(16.dp) ...
)

Upvotes: 35

Related Questions