如何计算字体大小不同的分辨率? [英] how to calculate font size for various resolution?

查看:573
本文介绍了如何计算字体大小不同的分辨率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想写通用$ C $下的所有决议。作为一个新的开发者正在逐渐停止用该字体的问题。想想我有不同的分辨率(100 * 100,200 * 200,300 * 300等).AM有一个TextView如果假设我设置字体大小为20 100 * 100,当我移植这个code至200 * 200,字体的大小似乎是非常小的分辨率200 * 200。任何能PLZ告诉如何计算字体大小不同的区域。是否有任何分子式可用来计算的话.. PLZ提醒..在此先感谢...

Am trying to write generic code for all the resolutions. Being a new developer am getting stopped by this font issue. Consider am having various resolutions ( 100 * 100, 200 * 200, 300 * 300 etc ).Am having a textview if suppose i set the font size as 20 for 100*100, when i am porting this code to 200*200, the size of the font seems to be very small for the resolution 200*200. Could any plz tell how to calculate font size for various regions. Is there any formual available to calculate it.. plz advise.. thanks in advance...

推荐答案

尝试使用 SP 单位的字体大小。

Try using sp unit for your font size.

SP

比例无关的像素 - 这是   像dp的单元,但也   由用户的字体大小缩放   preference。这是建议您使用   本单位指定的字体大小的时候,   因此它们将被调整为两个   屏幕像素密度和用户的preference。

Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference.

更多信息<一个href="http://developer.android.com/guide/topics/resources/more-resources.html#Dimension">here

取某个时候阅读理解在Andriod的使用,以及不同的计量单位。

Take sometime reading this to understand the different measurement units used in Andriod as well.

这篇关于如何计算字体大小不同的分辨率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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