简体   繁体   English

正常字体在某些设备上显示为斜体。 为什么以及如何修复?

[英]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.

相关问题 Android-共享首选项在某些设备上崩溃。 - Android - Shared Preferences crashes on some devices. 来自Gallary的Android Intent图片选择器...为什么不能在某些设备上显示? - Android Intent image picker from gallary… Why can't show in some devices.? 尝试使用Glide设置图像字符串。 这在某些设备中崩溃了。 怎么解决? - Trying to set image string from using Glide. This is crashing in some of the devices. how to solve it? 我的 androids 应用在某些设备上存在基于 Activitynotfoundexception 的崩溃。 我怎样才能再生它? - My androids app have Activitynotfoundexception based crashes on some devices. How can i regenerate it? 在某些设备上,我的android应用在Google Play商店中不可见。 - my android app is not visible in google play store for some devices.? 斜体提示文本,仅在某些设备上有效 - Italic hint text, only works on some devices 为什么旁遮普语(印度语)在某些智能设备上显示为盒子? - Why Punjabi (Indian Language) appears as boxes on some smart devices? 如何支持中文的斜体字体和粗体字体 - How to support italic font and bold font for Chinese 如何在两个Android设备之间使用套接字发送味精? - How to send msg using Socket between two android devices.? 在所有设备上具有相同的布局。 怎么样? - Having the extra same layout across all devices. How?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM