设备设置独立的字体大小字体大小、独立、设备

由网友(意中人)分享简介:在开发我的应用程序,我意识到,如果有人从正常更改设备字体大小,我的应用程序的字体大小改变也是一样,它破坏了一些,我设计的视觉效果。所以我想问是否有办法解决的文字,从设备的设置大小无关?While developing my app I realised if someone changes device font s...

在开发我的应用程序,我意识到,如果有人从正常更改设备字体大小,我的应用程序的字体大小改变也是一样,它破坏了一些,我设计的视觉效果。所以我想问是否有办法解决的文字,从设备的设置大小无关?

While developing my app I realised if someone changes device font size from normal, my application font sizes change too and it destroys some of the visuals I designed. So I wanted to ask if there is a way to fix text sizes independent from device's settings?

感谢

推荐答案

如果你想完全无视用户的字体大小preferences,然后用 DP 而不是 SP 的字体大小。棉绒会抱怨 DP 的使用(这是正确的,因为你有可能导致给用户带来不便,并有可能使您的应用程序无法使用为视障的),但你应该没有面对任何运行时的问题。

If you want to completely ignore user's font size preferences, then use dp instead of sp for font sizes. The lint will complain about the dp usage (and rightly so, because you are potentially causing inconvenience to the user and possibly rendering your app unusable for visually impaired ones), but you should not face any runtime issues.

如果你只是想忽略运行时的字体大小的变化,使用 fontScale:

If you just want to ignore runtime font size changes, use "fontScale":

<application android:label="@string/app_name"
    android:icon="@drawable/ic_launcher"
    ... >
    <activity android:name=".MyActivity"
        android:configChanges="fontScale">
        ...
    </activity>
</application>
阅读全文

相关推荐

最新文章