Android, Button view. The Button size is 38x38dp, text size is 20dp (just one +
character worth of text). Gravity is set to center|center_vertically.
The text is NOT centered vertically. According to Android's internal accounting, the text is too large for the specified button size, so the text is placed with its top aligned with the top padding, and its bottom cut off. That's not what I want; I want the text to be cut evenly on the top and on the bottom. In other words, vertically centered. The plus character, since it takes less than a full-sized character cell, won't suffer from that.
It's Gravity
that I set, not Layout gravity
. I know the difference.
Any ideas how to make vertical centering work in such conditions, short of overriding draw()?
Try adding android:includeFontPadding="false" to the Button view.
Some have suggested adding android:baselineAligned="false" to the container for similar problems but it didn't do anything for me.
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