Android 多屏支持问题
大家好,我一直在开发 Android 应用程序,它应该匹配大多数屏幕分辨率。我刚刚为这两个分辨率设置可绘制文件夹而感到震惊 1. 480 x 800,密度约为217 2. 540 x 960,密度约为 240
我对这两种分辨率都有一组不同的图像,并且我已将 hdpi 设置为 540 x 960,但不知道如何处理也属于 hdpi 的 480x800。仔细搜索发现一个名为 tvdpi 的可绘制限定符,它支持 appr。密度为 213
当我将 tvdpi 限定符设置为可绘制文件夹时,出现“无效的资源目录名称”错误
hi guys i have been developing android app that should match most of the screen resolutions. And i just got struck at setting the drawable folder for this two resolution
1. 480 x 800 with approximate density of 217
2. 540 x 960 with approximate density of 240
And i have a different set of images for both the resolutions and i have set hdpi for 540 x 960 but don't have an idea of going about the 480x800 which also falls under hdpi. After goggling found a drawable qualifier called tvdpi which supports the appr. density of 213
When i set the tvdpi qualifier to the drawable folder i get "invalid resource directory name" error
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
分辨率和 dpi 没有直接关系。碰巧的是,许多 800x480 设备都是 HDPI,那么如果屏幕足够大,也可以轻松采用低 dpi。
如果您确实需要直接分辨率匹配,则需要以 API 级别 13 为目标,并为您的资源使用可用的宽度和高度限定符,或者如果您需要以低于 13 的 API 级别为目标,请创建您自己的资源加载方案。
您还可以使用密度和尺寸限定符的组合,但这仍然为落入同一桶中的两种不同分辨率留下了一些空间。
但在选择之前,您需要问自己,您是否真的希望 3.7 英寸 480x800 屏幕上的可绘制元素与 7 英寸 480x800 屏幕上的像素大小相同。
Resolution and dpi are not directly related. It just so happens that many 800x480 devices are HDPI, then can just as easily be low dpi though if the screen is big enough.
If you really need direct resolution matching you will need to target API level 13 and use available width and height qualifiers for your resources or if you need to target a lower API level than 13, create your own resource loading scheme.
You can also use a combination of density and size qualifiers but that still leaves some room for two different resolutions falling into the same bucket.
But before you pick, you need to ask yourself do you really want the same pixel size for your drawables on a 3.7" 480x800 screen as you do for a 7" 480x800 screen.