如何防止系统字体大小更改对android应用程序的影响? [英] how to prevent system font-size changing effects to android application?

查看:277
本文介绍了如何防止系统字体大小更改对android应用程序的影响?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近完成了我的android应用程序的开发.我对所有textSize使用sp(缩放像素).问题是当我调整系统字体大小时,我的应用程序的字体大小正在更改.我可以使用dp(与设备无关的像素),但是维护我的应用程序会花费太长时间.

I recently finished developing my android application. I used sp (Scaled pixels) for all textSize. The problem is when i adjusted the system font-size, my application's font-sizes are changing. I can use dp (Device independent pixels) but it will take too long to maintain my application.

我从引用了文本大小.

有没有办法防止系统字体大小更改对我的应用程序的影响?

Is there a way to prevent system font-size changing effects to my application ?

推荐答案

如果您要求文本保持相同大小,则必须使用dp.

If you require your text to remain the same size, you'll have to use dp.

引用文档:

sp是相同的基本单位,但是根据用户首选的文本大小(它是与比例无关的像素)进行缩放,因此在定义文本大小时,您应使用此度量单位(但绝不会显示布局尺寸.

An sp is the same base unit, but is scaled by the user's preferred text size (it’s a scale-independent pixel), so you should use this measurement unit when defining text size (but never for layout sizes).

强调我的.

因此,您看到使用sp作为文本大小单位的预期行为.

So you're seeing the expected behaviour for using sp as your units for text size.

我不明白您对使用dp花费太长时间来维护应用程序的意思-据我所知,这是完全相同的工作量吗? (也许更少,尽管它可能会使视力不佳的用户无法使用它)

I don't understand what you mean about using dp taking too long to maintain your app - as far as I can tell, it'll exactly be the same amount of effort? (perhaps less, though it'll likely make it less usable for users with poor eyesight)

这篇关于如何防止系统字体大小更改对android应用程序的影响?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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