Implementing text vertical alignment in Android similar to Figma's Vertical Trim

Our team is working on a new Design System and we want to match the text alignment feature in Figma called Vertical Trim. We’re having trouble finding a good way to do this in Android.

We tried using android:includeFontPadding="false" but it didn’t work well. It cuts off accents on letters like Ś or Ć and still leaves extra space at the bottom.

There’s talk about a new CSS feature called leading-trim that might help with this kind of text alignment. But we can’t find anything similar for Android.

Here’s what we’re trying to achieve:

+---------------+
|   Text        |
| Aligned       |
| Vertically    |
+---------------+

Is there a way to get this kind of precise vertical text alignment in Android? We want to remove any extra space above and below the text, just like Figma’s Vertical Trim does. Any ideas or workarounds would be really helpful!

have you tried using custom TextViews with modified Paint settings? you could override onDraw() and adjust the baseline to remove extra space. might need some trial and error to get it perfect tho. another option is to use a custom font with adjusted metrics, but that’s more work upfront