简体   繁体   English

如何在Android编程中使用单个drawable用于所有屏幕分辨率?

[英]How to use single drawable for all screen resolutions in Android programming?

Android programming in eclipse, java, xml etc. I put all the drawables (images, xml files etc) in all the folders: mdpi, hdpi etc. So I have 4 copies of each file. 在eclipse,java,xml等中进行Android编程。我将所有drawables(图像,xml文件等)放在所有文件夹中:mdpi,hdpi等。所以我有4个副本的每个文件。

Is this absolutely necessary ? 这绝对有必要吗?

Is there a way I can put them in a single "drawable" folder ? 有没有办法将它们放在一个“可绘制”文件夹中?

Or will android understand that if the file does not exist in hdpi, it should fetch it from mdpi, or wherever the file exists ? 或者android会理解如果文件在hdpi中不存在,它应该从mdpi或文件存在的任何地方获取它?

Yes, it will fetch the appropriate file if that particular image is not available in other folder. 是的,如果该特定图像在其他文件夹中不可用,它将获取相应的文件。 But it need to atlest in one folder(drawable OR mdpi OR hdpi OR ldpi ...) 但它需要在一个文件夹中放置(可绘制OR mdpi或hdpi或ldpi ...)

Yes you can put all the images in single drawable folder.But in this case if you have a low resolution image this will be look as faded image in the case of tabs 是的,您可以将所有图像放在单个可绘制的文件夹中。但在这种情况下,如果您有一个低分辨率的图像,这将在标签的情况下看起来像褪色图像

so if you want your application support in all devices, Tabs then you have to put images in different drawable folder like as drawable-ldpi, drawable-mdpi, drawable-hdpi, drawable-xhdpi, drawable-xxhdpi 因此,如果您希望所有设备都支持应用程序,那么您必须将图像放在不同的可绘制文件夹中,如drawable-ldpi,drawable-mdpi,drawable-hdpi,drawable-xhdpi,drawable-xxhdpi

为什么不使用https://code.google.com/p/9patch-resizer/自动将图片大小调整为与Android开发兼容的所有分辨率?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM