This question is more about why Jetpack compose is so unintuitive. I am trying to better understand this library.
With the below composable
fun RoundedButton(modifier: Modifier, onClick: () -> Unit) {
Box(modifier = modifier.padding(horizontal = 10.dp)) {
Button(
onClick = { /* ... */ },
shape = CircleShape,
) {
// Inner content including an icon and a text label
Icon(
imageVector = Icons.Default.Add,
contentDescription = "Favorite",
modifier = Modifier.size(20.dp)
)
}
}
}
I get this
So one would assume, that in order to make it rounded I can just set the size (width and height) to an value, and if I do so
@Composable
fun RoundedButton(modifier: Modifier, onClick: () -> Unit) {
Box(modifier = modifier.padding(horizontal = 10.dp)) {
Button(
onClick = { /* ... */ },
shape = CircleShape,
modifier = modifier.size(40.dp)
) {
// Inner content including an icon and a text label
Icon(
imageVector = Icons.Default.Add,
contentDescription = "Favorite",
modifier = Modifier.size(20.dp)
)
}
}
}
I get this.
Question:
I do realise that there are other variations of Button
out there like IconButton
etc, but why make simple things so complicated that you cannot arrive at RoundedButton
or IconButton
from a Button
?