I have several TextViews in my application where I use a custom font. I set gravity to the center of the view so that the text is centered in the parent layout. It looks great in a preview program with a Sans font, but when I change the font, the result looks like the text is shifted down, for example:
Compared to this:
Here is the XML for this element:
<FrameLayout android:id="@+id/Turn_ScoreA_Frame" android:padding="5dp" android:background="@color/teamA_secondary" android:layout_margin="5dp" android:layout_gravity="center" android:layout_height="50dp" android:layout_width="110dp"> <android.view.View android:id="@+id/Turn_ScoreABG" android:background="@color/teamA_primary" android:layout_height="fill_parent" android:layout_width="fill_parent"></android.view.View> <TextView android:id="@+id/Turn_ScoreA" android:includeFontPadding="false" android:text="5" android:layout_gravity="center" android:layout_height="wrap_content" android:layout_width="wrap_content" android:textSize="32dp"></TextView> </FrameLayout>
This also happens when I use fill_parent for layout_width and height of the text view centered on the text. I installed a custom headset in an OnCreate view that uses this layout, just using TextView.SetTypeface.
Does anyone know what could be causing this? I have problems finding something in this direction.
As a note, I worked on this in several views, setting margin_bottom to -10dp or so, but I would like to remove it, and I can't get this hack to work with limited views like this one anyway.
By the way, the font is Anton.
UPDATE: This is definitely the result of too much text for its container. The fact is that Sans fits just fine, and the new font fits, but its size is too large. I hope to find a way to keep the text in its current visible size and fit in the center of the container so that it doesn't seem too hacky =)
source share