开发者

how to calculate font size for various resolution?

开发者 https://www.devze.com 2023-02-11 02:50 出处:网络
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

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*开发者_Go百科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...


Try using sp unit for your font size.

sp

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.

More information here

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

0

精彩评论

暂无评论...
验证码 换一张
取 消