[英]Drawable-hdpi, Drawable-mdpi, Drawable-ldpi Android
I was working on Android 1.5, but I have now moved to the latest version. 我正在使用Android 1.5,但我现在已经转移到了最新版本。 So there is only one "drawable" folder in Android 1.5, but now there are three different folders for storing images in the Android project. 因此Android 1.5中只有一个“drawable”文件夹,但现在有三个不同的文件夹用于在Android项目中存储图像。
And I have found some articles for these three folders that says 我发现这三个文件夹的一些文章说
But what is the exact purpose of these three folders and when should I use a particular folder to store images in? 但这三个文件夹的确切目的是什么?我应该何时使用特定文件夹存储图像?
To declare different layouts and bitmaps you'd like to use for the different screens, you must place these alternative resources in separate directories/folders. 要声明要用于不同屏幕的不同布局和位图,必须将这些备用资源放在单独的目录/文件夹中。
This means that if you generate a 200x200
image for xhdpi
devices, you should generate the same resource in 150x150
for hdpi
, 100x100
for mdpi
, and 75x75
for ldpi
devices. 这意味着如果为xhdpi
设备生成200x200
映像,则应在150x150
为hdpi
生成相同的资源,为mdpi
生成100x100
,为ldpi
设备75x75
ldpi
。
Then, place the files in the appropriate drawable resource directory: 然后,将文件放在适当的drawable资源目录中:
MyProject/
res/
drawable-xhdpi/
awesomeimage.png
drawable-hdpi/
awesomeimage.png
drawable-mdpi/
awesomeimage.png
drawable-ldpi/
awesomeimage.png
Any time you reference @drawable/awesomeimage
, the system selects the appropriate bitmap based on the screen's density. @drawable/awesomeimage
引用@drawable/awesomeimage
,系统都会根据屏幕的密度选择合适的位图。
I got one good solution. 我有一个很好的解决方案。 Here I have attached it as the image below. 在这里,我将其附加为下图。 So try it. 试试吧。 It may be helpful to you...! 它可能对你有帮助......!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.