Android多种屏幕尺寸和密度问题

发布于 2024-10-07 05:20:39 字数 435 浏览 5 评论 0原文

我的绘图遇到了一个真正的问题,我似乎无法弄清楚。

问题是这样的:

屏幕尺寸约为 320x480、480x800、480x854

然后最常见的密度为 1.0 (160) 和 1.5 (240)

现在,在 Droid 上,屏幕尺寸为 480x800,并且使用 DisplayMetrics 报告密度as 1.5

在 G1 上,它是 320x480 并以 1.0 的密度报告,

但平板电脑设备以 480x800 的密度报告返回,密度为 1.0 (160)

所以,我要疯了,因为我可以将 320x480 图像放入 drawables-mdpi文件夹和drawables-hdpi文件夹中的480x800图像,但在平板电脑上,无论如何它都不会将任何内容调整为全屏。

任何帮助将不胜感激。我只想放大所有 320x480 图像,无论设备如何。

I'm having a real problem with my drawables that I just can't seem to figure out.

The problem is this:

There are screen sizes at approximately 320x480, 480x800, 480x854

Then there are most commonly densities at 1.0 (160) and 1.5 (240)

Now, on a Droid, the screen size is 480x800 and the density is reporting using DisplayMetrics as 1.5

On the G1, it's 320x480 and reporting back at a density of 1.0

BUT tablet devices are reporting back at 480x800 with a density of 1.0 (160)

So, I'm going mad because I can put 320x480 images in the drawables-mdpi folder and 480x800 images in the drawables-hdpi folder, but on Tablet computers, no matter what it's not resizing up anything to a full screen.

Any help would be greatly appreciated. I just want all of my 320x480 images to scale up regardless of the device.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

长不大的小祸害 2024-10-14 05:20:39

您的清单中可能缺少一些标签,例如 anyDensitysupports...。只有 xlarge 才能提供不错的平板电脑支持(我认为是在 Gingerbread 中)。

另外,如果您自己绘图,则需要在画布、可绘制对象或位图(不记得三者中的哪一个)上调用 setTargetDensity(actualDensity) 。

You might be missing some tags in your manifest such as anyDensity and supports.... Decent tablet support only came with xlarge (in Gingerbread I think).

Also if you are drawing yourself, you need to call setTargetDensity(actualDensity) on your canvas, drawable, or bitmap (can't remember which of the three).

葬花如无物 2024-10-14 05:20:39

您如何应用这些图像?您可以仅使用 fill_parent 作为 ImageView 的layout_width/height,并选择 fitCenter 作为scaleType。

Galaxy Tab 报告为中 dpi 是完全正确的(尽管我认为 Tab 的分辨率是 1024 x 600?),即使它是高分辨率 分辨率 。 dpi 是像素大小的度量(例如,一英寸中的像素数)。因此,4 英寸屏幕中的 480 x 800 分辨率将比 7 英寸显示器中的 480 x 800 分辨率具有更高的 dpi,仅仅是因为它们被压缩到更小的空间中。

实际上,您可以添加一个名为 drawable-large-mdpi 的额外可绘制文件夹,其中可能包含大屏幕中 dpi 设备的文件,例如 Tab(请参阅 此处了解有关这些限定符的更多信息)。

How are you applying the images? You can just use fill_parent for the layout_width/height of an ImageView, and select fitCenter for the scaleType.

It's perfectly correct for the Galaxy Tab to be reporting as medium dpi (although I thought the resolution of the Tab was 1024 x 600?), even though it is a high resolution. The dpi is a measurement of the size of the pixels (e.g. the number of pixels in an inch). So a 480 x 800 resolution in a 4" screen will have a higher dpi than a 480 x 800 resolution in a 7" display, simply because they are compressed into a smaller space.

You can actually add an extra drawables folder called drawable-large-mdpi that could contain files for a large screened medium dpi device, such as the Tab (see here for more information on those qualifiers).

阪姬 2024-10-14 05:20:39

平板电脑出现问题。 Google 特别允许硬件制造商声明硬件 mpdi,即使 dpi 约为 160。Galaxy Tab 就是这样做的:http://realmike.org/blog/2010/12/21/multiple-screen-sizes-with-processing-for-android/< /a>

您可以尝试添加一个 res/drawable-mdpi-xlarge 并在此处添加 hdpi 图形。我认为 xlarge 是在 2.3 中引入的,旧的 Android 版本无法识别它。然后你可能想尝试drawable-mdpi-large(按照http://blog.alsutton.com/2010/07/03/android-tablets-and-mdpi-large/

添加额外的可绘制文件夹会增加 apk 的大小。一般来说,Gingerbread 或更好的 Honeycomb 之前的平板电脑在 Android 上很棘手,如果你能避免的话,我不会费心为它们做特殊的事情。

The tablet is doing something wrong. Google specifically made it possible for the hardware manufacturer to declare hardware mpdi even if the dpi is about 160. The Galaxy Tab does this: http://realmike.org/blog/2010/12/21/multiple-screen-sizes-with-processing-for-android/

You can try to add a res/drawable-mdpi-xlarge and add hdpi graphics here. xlarge was introduced in 2.3 I think, and older Android versions won't recognize this. You might want to try drawable-mdpi-large then (as per http://blog.alsutton.com/2010/07/03/android-tablets-and-mdpi-large/)

Adding extra drawable folders adds to the size of your apk. In general, tablets before Gingerbread or better Honeycomb are tricky on Android and I wouldn't bother to do special stuff for them if you can avoid it.

梦魇绽荼蘼 2024-10-14 05:20:39

为了在不失真或像素化的情况下缩放图像,Android 使用称为 9-patch 的图像。在这里阅读有关它们的更多信息:

http://developer.android.com/guide/developing /tools/draw9patch.html

但这或多或少有帮助,具体取决于您选择如何使用图像。 9 补丁工具对于壁纸应用程序来说是没有用的。

这是我在SO上找到的另一个链接:

http://www.developer.com/ ws/other/article.php/3889086

For scaling images without distortion or pixelization, Android uses images called 9-patch. Read more about them here:

http://developer.android.com/guide/developing/tools/draw9patch.html

But this is more or less helpful depending on how you choose to use the images. The 9 patch tool would be of no use for say, a wallpaper application for instance.

Here is another link I found on SO:

http://www.developer.com/ws/other/article.php/3889086

随波逐流 2024-10-14 05:20:39

按照链接操作
您可能需要为您的应用程序创建不同的屏幕尺寸和密度 res 文件夹组合。
浏览不同的限定符名称并进行试验。

http://developer.android.com/guide/practices/screens_support.html

Follow the link
you may require to create different combinations of screen size and densities res folders for your app.
Go through different qualifier names and experiment with them.

http://developer.android.com/guide/practices/screens_support.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文