`
tudusi
  • 浏览: 1052234 次
文章分类
社区版块
存档分类
最新评论

res/drawable-xhdpi文件夹下的资源文件无法应用程序无法识别

 
阅读更多

项目要做平板支持 (MotorolaXoom 3.0),客户要求使用高分辨率图片。

Motorola Xoom的 resolution是 1280X800

因为:

  • xlarge screens are at least 960dp x 720dp
  • large screens are at least 640dp x 480dp
  • normal screens are at least 470dp x 320dp
  • small screens are at least 426dp x 320dp
所以它属于 xlarge,因此可以将针对它的布局文件放在res/layout-xlarge 资源文件夹下。如果你采用3.2sdk来编译的话,针对 Motorola Xoom 3.0这一款 Tablet,可以将它的布局文件放在res/layout-sw720dp 资源文件夹下特别注意:这种命名方式3.2以后的adk才支持!)

布局文件是找到了,可是密度density方面,显示我的Tablet没有找到 res/drawable-xhdpi ,唯一的解释是这个Tablet密度 density不是 xhdpi的(320)。


参考:

Density ldpi Resources for low-density (ldpi) screens (~120dpi).
mdpi Resources for medium-density (mdpi) screens (~160dpi). (This is the baselinedensity.)
hdpi Resources for high-density (hdpi) screens (~240dpi).
xhdpi Resources for extra high-density (xhdpi) screens (~320dpi).
nodpi Resources for all densities. These are density-independent resources. The system does notscale resources tagged with this qualifier, regardless of the current screen's density.
tvdpi Resources for screens somewhere between mdpi and hdpi; approximately 213dpi. This is notconsidered a "primary" density group. It is mostly intended for televisions and most apps shouldn'tneed it—providing mdpi and hdpi resources is sufficient for most apps and the system willscale them as appropriate. If you find it necessary to provide tvdpi resources, you should size themat a factor of 1.33*mdpi. For example, a 100px x 100px image for mdpi screens should be 133px x133px for tvdpi.


那么,如何得知我平板的屏幕显示密度呢?

知道屏幕的尺寸、分辨率,怎样计算它的像素密度?

答案:
分辨率的平方和开根号,除以屏幕尺寸(平时所说的几英寸都是只斜对角线长度)。

计算出的结果,差不是 149.449,原来不是 ~320dpi,差不多 ~150dpi,
这也就解释了,为什么我放在xhdpi资源文件夹下的图片资源都没有被识别到!

注:
dpi是“dot per inch”的缩写,每英寸像素数。
1英寸 = 2.54厘米

-------------------------------------------------------------------

总结:
   显示效果的好坏,与分辨率 和 密码的大小有关,我的平板只有 ~150dpi,虽然它有1280X800的resolution.
但还是显示的比较模糊,山寨感较强。而我的手机(htc desire G7),显示效果特别华丽,因为它的屏幕只有3.7inch
,而resolution为800X480,计算出的dpi是 252.149,所以显示得比较清晰。

   当运行app时,Motorola Xoom使用默认drawable-mdpi资源文件夹下的资源图片,而htc g7则使用drawable-hdpi资源
文件夹下的图片。







分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics