When a Box is clickable and has padding via Modifi...
# compose
t
When a Box is clickable and has padding via Modifierer the clickbox will only contain the content. Is this a bug or a feature? Solved
1
Source Code:
Copy code
@Composable
fun MainContent() {
    Row(
        horizontalArrangement = Arrangement.spacedBy(16.dp),
        modifier = Modifier
            .background(MaterialTheme.colors.primary)
            .padding(16.dp)
            .clickable { println("Click") }
    ) {
        Icon(
            imageVector = Icons.Filled.Add,
            contentDescription = "Add icon",
            tint = MaterialTheme.colors.onPrimary,
            modifier = Modifier as Modifier
        )
        Text("Add new", color = MaterialTheme.colors.onPrimary, fontWeight = FontWeight.Normal)
    }
}
j
I think it’s a feature, you should try inverting the modifier and you should achieve the opposite effect.
👍 2
s
@TheMrCodes order matters. please try swapping
padding
and
clickable
lines
👍 3
t
Thanks my bad. Works flawlessly with reversed order 👍
👍🏻 1