Android的资源大小预选赛 [英] Android resource size qualifier

查看:147
本文介绍了Android的资源大小预选赛的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法从价值观sw480dp我也不索尼Xperia设备,其480 * 854既不在三星Galaxy Tab是600 x 1024时,但能够获得摩托罗拉Xoom是1280 * 752上得到的值。

I unable to get the values from "values-sw480dp" nor on my sony Xperia device which is 480 x 854 neither on Samsung galaxy tab which is 600 x 1024. But able to get on Motorola Xoom which is 1280 x 752.

例如RES /价值观sw480dp / strings.xml中/

<string name="hello_world">hello world</string>

在各个设备中的值

索尼Xperia ----> @ 2131034113

Sony Xperia ----> @2131034113

三星----> @ 2131034113

Samsung ----> @2131034113

在XOOM --->的Hello World

on xoom ---> hello world

任何一个可以解释我这种行为,为什么索尼Xperia和三星有@ 2131034113的价值。

Can any one explain me this behavior, why Sony Xperia and Samsung has "@2131034113" value.

感谢您提前

推荐答案

据的 http://developer.android.com/guide/topics/resources/providing-resources.html ,sw480dp意味着«屏幕的最小边必须至少有480 DP»。现在 DP 是一个«上一个160 dpi的屏幕像素»,例如的实际如此规模在的Xperia DP 将是我猜320×569(只要它是一个华电国际设备)。

According to http://developer.android.com/guide/topics/resources/providing-resources.html, sw480dp means «smallest side of screen must be at least 480 dp». Now dp is a «pixel on a 160 dpi screen», so actual size of e.g. Xperia in dp would be I guess 320 x 569 (provided it's a hdpi device).

要获得 DP 设备的屏幕尺寸,你需要知道抽象类密度(LDPI = 120,MDPI = 160,华电国际= 240,xhdpi = 320)。对于上述的Xperia屏幕的计算方式为:(480 * 160/240)×(854×160/240),其中160是基本密度(这是其中1 DP 实际上等于一个像素)和240设备抽象密度。

To get device screen size in dp you need to know abstracted density class (ldpi=120, mdpi=160, hdpi=240, xhdpi=320). For the above Xperia screen the calculation is: (480*160/240) x (854*160/240), where 160 is the base density (it's where 1 dp actually equal to one pixel) and 240 is device abstracted density.

这篇关于Android的资源大小预选赛的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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