Android的资源大小预选赛预选赛、大小、资源、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 son...

我无法从价值观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.

阅读全文

相关推荐

最新文章