Jetpack compose provides a nice Icon() object to display icons that accepts a vector asset. Typically, you are able to set the size via a modifier:
Icon(Icons.Filled.PersonPin, Modifier.preferredSize(64.dp))
My problem is I cannot seem to affect the size of the displayed icon when I am using a provided system vector asset (ie, Icons.Filled. or Icons.Default. etc). When I use my own asset, things work as expected. Using the system assets the modifier only increases the UI footprint of the enclosing "box" while the icon stays tiny within:
Applying the modifier using 'then' results in the same behavior:
Icon(Icons.Filled.PersonPin,Modifier.then(Modifier.preferredSize(128.dp)))
Is there something about the native icons? I assumed being vector assets they should be able to resize as well.
To use Icon , include the Compose Material library (or the Compose Material 3 library). By default, the Icon composable is tinted with LocalContentColor. current and is 24. dp in size.
To draw an icon, you can use the Icon composable which applies tint and provides layout size matching the icon. Some of the most commonly used icons are available as part of the androidx. compose.
How to disable ripple effect in Jetpack Compose? Using the Mutable Interaction Source. Create a Custom MutableInteractionSource Class. Create a Custom No Ripple Theme.
Scaffold provides slots for a top app bar or a bottom app bar. The placement of the composables is handled internally. These slots can be used for other Material Components like BottomNavigation . You can also use custom composables — for an example, take a look at the onboarding screen from the Owl sample.
With 1.0.x
just use the Modifier.size(xx.dp)
Icon(Icons.Filled.Person,
"contentDescription",
modifier = Modifier.size(128.dp))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With