I'm testing the Segmented Button for my app. At th...
# compose-android
n
I'm testing the Segmented Button for my app. At the moment I am using the code from the doc, and my own text and icons. It seems to me that the icons are not vertically aligned. Is there a way of aligning them?
e
Your Media icon seems to be aligned. Does the messages icon have any padding in the icon itself?
k
Some of these are top heavy and some are bottom heavy. Looks like your icon library doesn’t do “optical” alignment of content in the icon bounds.
n
I'm using icons_extended.
k
We had a similar optical alignment issue with Play Store triangle icon in a notification shade circle. Moving the icon manually one pixel to the right in its box “solved” it.
n
Hmm, how to move them manually though, as I am looping through the list? I'm a bit confused. I might try to source the icons from somewhere else...
k
It would either be an icon library that accounts for how the “mass” is distributed and optically centers that mass in each icon’s bounds, or choosing an icon library that uses shapes that do not tilt their mass to one of the edges
There is no concept of icon baseline like there is with text, and as in my example of Play Store, the misalignment was along the other axis in any case
n
It's strange though that the official material icon library (material-icons-extended) has this weird drawback...
k
Really depends on how you’re using the icons. You can argue that doing some sort of optical vertical alignment should be the default mode.
n
Fair enough, it just looks a bit off to me but I may be focusing on it too much. 😊
a
In my quick testing, it seems that
SegmentedButtonDefaults.Icon()
is what messes up vertical alignment, as without it they're completely fine:
image.png
n
Ooh excellent, thanks for this! 😊