Android font size difference issue on gingerbread

2019-09-16 17:24发布

问题:

Emulator/Device Specs:

HDPI

RESOLUTION 1280 x 800

SCREEN SIZE 5.3

Following two images are captured from two emulators with specs mentioned above. Both emulators have everything same except OS version

ANDROID 2.3.5 (Gingerbread)

ANDROID 4.1.1 (Jelly Bean)

I have used a custom background image for EditText. For EditText android:textAppearance property is set to 70sp for both emulators.

So, my question is why on Jelly Beans text size is bigger than text size on gingerbread?

Note: This issue is also seen on ICS.

UPDATE:

This is what i am getting now after making the EditText background image nine-patch. The text is not fit inside the EditText

Following are the EditText properties in XML.

 <EditText
        android:id="@+id/phone_number"
        android:layout_width="fill_parent"
        android:layout_height="150dip"
        android:layout_gravity="center"
        android:layout_marginLeft="28dip"
        android:layout_marginRight="28dip"
        android:background="@drawable/lcdscreen_no_glow"
        android:singleLine="true" 
        android:maxLength="12"
        android:inputType="phone"
        android:textAppearance="@style/EditTextStyleMedium"      
        android:gravity="center"
        android:textStyle="bold"
        android:clickable="false"
        android:longClickable="false"
        android:cursorVisible="false"/>

回答1:

I have used a custom background image for EditText

That background image should be a nine-patch PNG file so that it can stretch accordingly.

So, my question is why on Jelly Beans text size is bigger than text size on gingerbread?

If nothing else, the default font is different. Android 1.x/2.x used the Droid font family, while Android 4.x uses Ruboto. Since, by eyeball, the heights appear the same, the Ruboto glyphs for 9 are apparently wider.