Gleb Sabirzyanov
Gleb Sabirzyanov

Reputation: 775

Normal font appears italic on some devices. Why and how to fix?

The problem is that text in TextView looks fine on Android emulator, but it doesn't on the actual device. This is not my device and I'm not familiar with Android system, so I don't know if it's somehow overridden by system settings.

Here is how it looks on the emulator:

Emulator screenshot

And here is how it looks on the device:

Actual device

TextView:

<TextView
    android:id="@+id/text_header"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textAppearance="@style/AppTheme.Text.StepperHeader"
    android:text="Header"/>

Style:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- No text-related settings here. -->
</style>

<style name="AppTheme.Text">
    <item name="android:textColor">#1F1F1F</item>
</style>

<style name="AppTheme.Text.StepperHeader">
    <item name="android:textSize">14sp</item>
</style>

If the problem is in AppCompat theme as a parent — which one should I use instead? I want a consistent app look on all devices. Can you explain why it's happening and how to fix it?

Upvotes: 2

Views: 297

Answers (1)

Ugurcan Yildirim
Ugurcan Yildirim

Reputation: 6132

To be able to get same font result on (almost) every device, use a custom font. You can download one from websites like DaFont, etc. Then, you can apply your custom font easily (and without a need to get into the details of Android styles) to your UI widgets using Calligraphy library. See its piece-of-cake documentation for examples usage.

Upvotes: 1

Related Questions