简体   繁体   English

如何针对不同的屏幕密度确定字体大小?

[英]How to target font sizes for different screen densities?

I am developing an android tablet application. 我正在开发一个Android平板电脑应用程序。 To support different screen sizes I am using resource qualifiers 为了支持不同的屏幕尺寸,我正在使用资源限定符

  • sw600dp - Nexus 7 like screens sw600dp-Nexus 7萤幕
  • sw768dp - Nexus 9 sized screens sw768dp-Nexus 9尺寸的屏幕
  • sw800dp - Nexus 10 sized screens sw800dp-Nexus 10尺寸的屏幕
  • sw840dp - Pixel C Sized screens sw840dp-Pixel C尺寸的屏幕

Now I came across a situation where the same 10 inch screen has different densities. 现在,我遇到了相同的10英寸屏幕具有不同密度的情况。

Nexus 10 @density 2.0 Nexus 10 @密度2.0

Kindle Fire 10 @density 1.5 Kindle Fire 10 @密度1.5

Both these devices are fetching the values from the sw800dp folder. 这两个设备都从sw800dp文件夹中获取值。 But in nexus 10 the font sizes are normal and on Kindle Fire 10 HD the font sizes are very large. 但是在nexus 10中,字体大小是正常的,而在Kindle Fire 10 HD上,字体大小非常大。

What's the best way to target these two types of screens? 针对这两种类型的屏幕的最佳方法是什么?

Also am I following the correct method in targeting multiple screen sizes? 我是否也遵循针对多个屏幕尺寸的正确方法?

For Nexus 10 font size, create res folder. 对于Nexus 10字体大小,请创建res文件夹。 by default is portrait. 默认情况下为纵向。

values-sw720dp-land

在此处输入图片说明 Happy coding!! 编码愉快!!

Make folders like this 像这样制作文件夹

values // default values 值//默认值

values-sw400dp 值-sw400dp

values-sw600dp 值-sw600dp

values-sw800dp 值-sw800dp

create dimen file in each folder for diffrent screen wise size 在每个文件夹中创建尺寸不同的屏幕尺寸的dimen文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM