[英]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.问题是
TextView
中的文本在 Android 模拟器上看起来不错,但在实际设备上却没有。 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.这不是我的设备,我不熟悉Android系统,所以我不知道它是否被系统设置覆盖。
Here is how it looks on the emulator:这是它在模拟器上的样子:
And here is how it looks on the 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?如果问题出在
AppCompat
主题中作为父主题 - 我应该使用哪个? I want a consistent app look on all devices.我希望在所有设备上都有一致的应用程序外观。 Can you explain why it's happening and how to fix it?
你能解释为什么会发生这种情况以及如何解决吗?
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.
您可以从DaFont等网站下载一个。然后,您可以使用Calligraphy库轻松地将您的自定义字体(无需深入了解 Android 样式的详细信息)应用于您的 UI 小部件。 See its piece-of-cake documentation for examples usage.
有关示例用法,请参阅其小文件文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.