本文介绍了如何MDPI,华电国际,xhdpi文件夹的作品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

:从上面的Andr​​oid开发者指南链接

提取

所以我得到的图形(图像)的分辨率每英寸320像素的设计师在这方面只有

480×800华电国际

720x1280 MDPI

800x1280 MDPI

我很困惑哪些图像的大小应放置在MDPI夹,HDPI夹和xhdpi夹。我想打它可以在大多数Android手机和平板电脑工作的一个应用程序?

解决方案

您可以创建不同的图形对象使用不同的像素密度。机器人治疗MDPI(160像素/英寸)为基料的密度。因此对于MDPI装置,1 DP = 1个像素。在更高的密度,有每英寸更多的像素(240 HDPI,320为xhdpi)。机器人试图使图形图像在屏幕上占据了相同的物理尺寸而不管所述装置的像素密度。因此,如果所有它发现是一个MDPI资源,并且该装置是HDPI,它将缩放图形由一百六十零分之二百四十零= 150%,它会增​​加一倍图形为xhdpi的大小。

如果你不希望这个自动缩放(它可以使图形看起来差),你可以简单地提供自己版本的图形资源的使用,在更高的密度。这些图形应该是机器人将缩放MDPI资源的大小相同。

请注意该已存储的图像文件中的像素/英寸无关与此有关。这一切都基于你把图形文件中的资源目录为您的项目。放在 RES任何图形/绘制被认为是适当的大小为MDPI显示,因为是图形放在 RES /绘制-MDPI 。中发现的图像文件 RES /绘制,华电国际被认为是适当的大小为华电国际显示器,等等。当你的程序特定的设备上运行,Android将首先寻找的图形,这一装置的显示密度相匹配。如果它没有找到一个,而是发现一个用于一个不同的密度,将使用和基于上述规则自动缩放图像。

Extract from Android Developer Guide link above:

So i got graphics(images) at resolution 320 pixels per inch from designer in these dimension only

480x800 hdpi

720x1280 mdpi

800x1280 mdpi

I am confused which size of images should be placed in mdpi folder, hdpi folder and xhdpi folder. I want to make one application which can work on most android phones and tablets ?

解决方案

You can create different graphic objects for use at different pixel densities. Android treats mdpi (160 pixels/inch) as the base density. So for mdpi devices, 1 dp = 1 pixel. At higher densities, there are more pixels per inch (240 for hdpi, 320 for xhdpi). Android attempts to make graphic images occupy the same physical dimensions on the screen regardless of the device pixel density. So if all it finds is an mdpi resource, and the device is hdpi, it will scale the graphic by 240/160 = 150%, and it will double the size of the graphic for xhdpi.

If you don't want this automatic scaling (which can make graphics look poor), you can simply supply your own version of graphic resources for use at higher densities. These graphics should be of the same size that Android would scale an mdpi resource.

Note that the pixels/inch that was stored in the image file has nothing to do with this. It's all based on where you put the graphics files in the resources directory for your project. Any graphics placed in res/drawable are assumed to be properly sized for mdpi displays, as are graphics placed in res/drawable-mdpi. Image files that it finds in res/drawable-hdpi are assumed to be properly sized for hdpi displays, etc. When your program runs on a particular device, Android will first look for a graphic that matches the display density of that device. If it does not find one but instead finds one for a different density, it will use that and automatically scale the image based on the above rules.

这篇关于如何MDPI,华电国际,xhdpi文件夹的作品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 20:42