Android的资源文件夹按屏幕尺寸 [英] Android Resources Folders by Screen Size

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

问题描述

我deloped一个Android游戏,几乎支持分辨率在市场上(240×320,小320x480,480x800的,为480x854,600x1024)。

I've deloped an Android game which supports almost resolutions in the market (240x320, 320x480, 480x800, 480x854, 600x1024).

我的问题是,当我试图支持平板电脑,我不明白为什么Android的差距在不同的文件夹(华电国际,LDPI,MPDI,大MDPI,...)时限定词是不是有用的资源! 我有几个图形套(根据宽度),但我要疯了,例如,随着平板电脑与480x800的密度MDPI和LDPI!它是不可能达到每个设备。

My problem is when I'm trying to support tablets, I don't understand why Android divide the resources in different folders (hdpi, ldpi, mpdi, large-mdpi, ...) when that qualifiers isn't useful! I have several graphics sets (according width) but I'm going crazy, for example, with the tablets 480x800 with density mdpi or ldpi! It's is impossible reach every device.

那么,你知道任何方式来划分的文件夹中可绘制/位图,但只有入店通过的决议?是的,我知道,位图别名,但它不是解决办法。

So, do you know any way to divide drawables/bitmaps in folders but only accesible through resolution?? Yes, I know Bitmap Alias but it's not the solution.

感谢

推荐答案

我相信你是混合的屏幕尺寸与像素密度:

I believe you're mixing screen size with pixel density:

从开发指南:

      
  • 在该平台支持一组资源预选赛,让你提供大小 - 和密度特定资源,如果需要的。预选赛尺寸为特定的资源正常 XLARGE 。那些密度相关的资源 LDPI (低), MDPI (中等),华电国际(高),而 xhdpi (特高)。预选赛对应于范围描述支持屏幕的广义密度,上述
  •   
  • 在该平台还提供 &LT ;支持屏> 清单元素,其属性安卓smallScreens 安卓normalScreens 安卓largeScreens 安卓xlargeScreens 让你指定什么广义屏尺寸应用程序支持。另一个属性,机器人:anyDensity,您可以指示是否您的应用程序包括内置的多种密度的支持
  •   
  • The platform supports a set of resource qualifiers that let you provide size- and density-specific resources, if needed. The qualifiers for size-specific resources are small, normal, large, and xlarge. Those for density-specific resources are ldpi (low), mdpi (medium), hdpi (high), and xhdpi (extra high). The qualifiers correspond to the generalized densities described in Range of screens supported, above.
  • The platform also provides a <supports-screens> manifest element, whose attributes android:smallScreens, android:normalScreens, android:largeScreens, and android:xlargeScreens let you specify what generalized screen sizes your application supports. Another attribute, android:anyDensity, lets you indicate whether or not your application includes built-in support for multiple densities.

修改:增加了我的意见,以响应

在注释中使用的示例中,爱可视是一个7英寸的屏幕,而Nexus One的拥有一块3.7英寸的屏幕。 在相同的像素数量,像素密度为双在Nexus One上。请记住,DPI是指每英寸的点数。 这意味着,相同的图像将呈现大两倍的爱可视比Nexus One的

Using the example in the comment, the Archos is a 7 inches screen, while the Nexus One has a 3.7 inches screen. At the same number of pixels, the density of pixels is double on the Nexus One. Remember, dpi means dots per inch. That means that the same image would be rendered twice as big in the Archos than in the Nexus One.

的屏幕尺寸差异应该在布局进行处理。使用 RES /布局正常的Nexus One的和 RES /布局大的爱可视。通过这种方式,你将有超过为不同的屏幕尺寸(也许你需要限制一些小部件,这将是在爱可视不必要的大)版式的完全控制,并决定是否要保持一个固定大小的可绘制或扩展他们作为有必要的。

The screen size differences should be handled in the layout. Use res/layout-normal for the Nexus One and res/layout-large for the Archos. This way, you will have control over the full layout for the different screen sizes (perhaps you need to limit some widgets that would be unnecessarily large in the Archos) and decide whether you want to keep a fixed size for your drawables or expand them as necessary.

另外,如果你真的想保持屏幕尺寸和的大小成比例的屏幕,无论无拉伸图片的,那么你就可以创建两套图像,即此搜索-normal.png,image2- normal.png与此搜索-large.png,IMAGE2-large.png等,无论是在 RES /绘制-MDPI RES /绘制-hdpi 文件夹,你会从XML文件访问 RES /布局正常 RES /布局,大

Alternatively, if you really want to keep size proportional to the screen regardless of screen size and without stretching images, then you can create two sets of images, namely image1-normal.png, image2-normal.png and image1-large.png, image2-large.png, etc, both in the res/drawable-mdpi and the res/drawable-hdpi folders, that you would access from the xml files in res/layout-normal and res/layout-large.

在摘要,全部要求应当由布局和可绘制的组合处理的:

In summary, the full requirements should be handled by a combination of layouts and drawables:

  • 的Nexus One 布局正常绘制 - 华电国际
  • 爱可视7 布局大绘制-MDPI
  • 的Xoom 布局XLARGE 绘制-MDPI
  • Nexus One: layout-normal, drawable-hdpi
  • Archos 7: layout-large, drawable-mdpi
  • Xoom: layout-xlarge, drawable-mdpi

这篇关于Android的资源文件夹按屏幕尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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