https://kotlinlang.org logo
#compose
Title
# compose
j

József Szilvási

02/16/2021, 1:07 PM
I know it has been asked before, but I haven’t seen any answers yet. Is there any way to strip the vertical padding off of the fonts? Something like a replacement for:
Copy code
android:includeFontPadding="false"
android:lineSpacingExtra="0dp"
1
d

Denis

02/16/2021, 1:36 PM
search "TextDelegate", there was a good answer a week ago
ah, sorry. It's actually a slightly different problem. I also didn't find an easy solution. But I use TextDelegate to render 2 lines, then render only the second line on a Canvas
lineHeight doesn't work as expected for some reason for the first line, that's why you need 2 lines
I used • TextDelegate to layout 2 lines of text: first - empty, second - actual text • ParagraphStyle to set lineHeight=1.sp in annotated string. •
translate
function within Canvas to "hide" the first line. LayoutResult gives you baselines, lines' top/bottom coordinates
j

József Szilvási

02/17/2021, 7:20 AM
Thanks! (This doesn’t sound like an out-of-the-box solution 😄)
r

Ravin Jain

09/07/2021, 5:41 PM
@József Szilvási Did u find any solution for this? I am trying to remove the vertical padding on text
j

József Szilvási

09/07/2021, 5:48 PM
Unfortunately no, I ended up using a different font with less padding. This is the ticket for the long awaited solution: https://issuetracker.google.com/issues/171394808
🙏 1