Inappropriate Roboto Font Height

I am currently having problems with the Android Roboto font. At first I had two TextViews in one horizontal LinearLayout, centered both vertically and horizontally. The first TextView installed the font Roboto-Black.ttf, and the second - Roboto-Light.ttf. Both were set to textSize = "12sp", but one with Roboto-Light.ttf was just a pixel taller than Roboto-Black.ttf TextView. But this did not happen when I set textSize = "13sp". Therefore, I created a new Android project to make sure that it is not only in one application. The result is almost identical, but in this case textSize = "12sp" works as expected, but textSize = "13sp" does not. I took screenshots to show the problem.

12sp works as expected. Top edges aligned. image

13sp has such weird behavior. image

It is strange that this happens only when I try to mix thin and thick aligned options. When I make one TextView Roboto-Bold.ttf and a second Roboto-Black.ttf, the result is good. When I try Roboto-Light.ttf and Roboto-Thin.ttf, it also works correctly.

So I also tried checking this out in Photoshop, and here is what I found:

image

This is the same for all fonts in the Roboto family except Roboto-Light.ttf. I can also send the source code of the layout if necessary.

Thanks in advance.

PS: Sorry for the links, but due to the low reputation (new account) I can not send images. Also in the last link, I had to remove "h" from "http" because it did not allow me more than two links.

+7
source share
1 answer

I can’t tell you if there are fonts in it or how your phone interprets fonts and displays them on the screen, but I can say that I used to have problems with centering in the middle.

Have you tried using relativelayout and then aligned the second top text and bot with the first text view? This may solve the problem.

+1
source

All Articles