Our team is working on a design system where we need to replicate Figma’s Vertical Trim functionality in Android.
I’m struggling to find a proper way to remove the extra vertical spacing from TextViews that appears above and below the actual text content. This spacing makes it hard to achieve pixel-perfect designs that match our Figma mockups.
What I’ve tried so far:
Using android:includeFontPadding="false" but this approach has problems:
- It cuts off accented characters like Ą or Ź
- Bottom spacing still remains visible
- Doesn’t work consistently across different font families
Example of the issue:
<TextView
android:id="@+id/titleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sample Header Text"
android:textSize="24sp"
android:includeFontPadding="false"/>
Even with includeFontPadding set to false, there’s still unwanted vertical space that prevents accurate spacing between UI elements.
Is there a native Android solution to achieve true vertical text trimming similar to what Figma offers?