When I have a TextView
with a \n
in the text,, on the right I have two singleLine
TextView
s, one below the other with no spacing in between. I have set the following for all three TextView
s.
android:lineSpacingMultiplier="1"
android:lineSpacingExtra="0pt"
android:paddingTop="0pt"
android:paddingBottom="0pt"
The first line of the left TextView
lines up perfectly with the top right TextView
.
The second line of the left TextView
is a little higher than the second line of the bottom right TextView
.
It seems that there is some kind of hidden padding on the top and the bottom of the TextView
s. How can I remove that?
or in
XML
this would be:Set whether the
TextView
includes extra top and bottom padding to make room for accents that go above the normal ascent and descent. The default is true.This annoyed me too, and the answer I found was that there is actually additional space in the font itself, not the TextView. It is rather irritating, coming from a document publishing background, the limited amount of control you have with Android over typographic elements. I'd recommend using a custom typeface (such as Bitstream Vera Sans, which is licensed for redistribution) that may not have this issue. I'm not sure specifically whether or not it does, though.
You might want to try aligning the bottom of the left text view with the bottom of the 2nd right text view.
I feel your pain. I've tried every answer above, including the
setIncludeFontPadding
to false, which did nothing for me.My solution?
layout_marginBottom="-3dp"
on theTextView
gives you a solution for the bottom, BAM!Although, -3dp on
layout_marginTop
fails....ugh.I think this problem can be solved in this way:
Those are the results:
ScreenShot-1
ScreenShot-3
Though the line of special characters in rightLowerText looks a little bit higher than the second line of leftText, their baselines are stilled aligned.
Use this in your ImageView xml
android:adjustViewBounds="true"