Android应用程序中TextView的字体大小在从本机设置更改字体大小时发生变化 [英] Font size of TextView in Android application changes on changing font size from native settings

查看:21
本文介绍了Android应用程序中TextView的字体大小在从本机设置更改字体大小时发生变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序中指定我自己的文本大小,但我在执行此操作时遇到了问题.

I want to specify my own text size in my application, but I am having a problem doing this.

当我在设备设置中更改字体大小时,我的应用程序 TextView 的字体大小也会发生变化.

When I change the font size in the device settings, the font size of my application TextView also changes.

推荐答案

其实设置字体大小只影响sp中的大小.所以您需要做的就是在 dp 中定义 textSize 而不是 sp,然后设置不会改变您应用中的文本大小.

Actually, Settings font size affects only sizes in sp. So all You need to do - define textSize in dp instead of sp, then settings won't change text size in Your app.

这里是文档的链接:Dimensions

但请注意,预期行为是所有应用程序中的字体都尊重用户的偏好.用户可能想要调整字体大小的原因有很多,其中一些甚至可能是医疗 - 视障用户.对文本使用 dp 而不是 sp 可能会导致不情愿地歧视您应用的某些用户.

However please note that the expected behavior is that the fonts in all apps respect the user's preferences. There are many reasons a user might want to adjust the font sizes and some of them might even be medical - visually impaired users. Using dp instead of sp for text might lead to unwillingly discriminating against some of your app's users.

即:

android:textSize="32dp"

这篇关于Android应用程序中TextView的字体大小在从本机设置更改字体大小时发生变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆