[英]single image for all ldpi, mdpi, hdpi, xhdpi in android
Perhaps we use one image for all ldpi, hdpi, mdpi and xdpi where we need to keep the image(in which folder). 也许我们对所有ldpi,hdpi,mdpi和xdpi使用一张图像,而我们需要将该图像保存在哪个文件夹中。 This is a bit confusion to me.
这对我来说有点混乱。 Can anybody clarify my confusion?
谁能澄清我的困惑?
只需将其保存在res/drawable
。
This is not recommended as the images you use will then not scale well for different device screen sizes. 不建议这样做,因为您使用的图像对于不同的设备屏幕尺寸将无法很好地缩放。 But if you place an image in
res/drawable
this will work. 但是,如果将图像放置在
res/drawable
它将起作用。
Instead of creating all of the different folder buckets, drawable-ldpi
, drawable-hdpi
, etc. Just create one folder, drawable
, and then put your images in there and when Android searchs for the image and doesn't find the other folders it will default to the drawable
folder as the only resource. 无需创建所有不同的文件夹存储桶,而是
drawable-ldpi
, drawable-hdpi
等。只需创建一个文件夹drawable
,然后将图像放在其中,当Android搜索图像而找不到其他文件夹时,将默认为drawable
文件夹作为唯一资源。 This folder is understood by Android to be equal to the drawable-mdpi
and will scale the images accordingly. Android将此文件夹理解为等于
drawable-mdpi
,并将相应缩放图像。
EDIT: Also available is the res/drawable-nodpi
, This will not scale your image at all and it will retain the same size on all screens. 编辑:
res/drawable-nodpi
也可用,这根本不会缩放图像,并且在所有屏幕上都将保持相同大小。
Take a look at How to Support Multiple Screens 看看如何支持多个屏幕
The "default" resources are those that are not tagged with a configuration qualifier.
“默认”资源是那些没有用配置限定符标记的资源。 For example, the resources in drawable/ are the default drawable resources.
例如,drawable /中的资源是默认的drawable资源。 The system assumes that default resources are designed for the baseline screen size and density, which is a normal screen size and a medium density.
系统假定默认资源是为基线屏幕尺寸和密度(正常屏幕尺寸和中等密度)设计的。 As such, the system scales default density resources up for high-density screens and down for low-density screens, as appropriate.
这样,系统会适当地按比例将默认密度资源扩大到高密度屏幕,并缩小到低密度屏幕。
So yes, drawable folder is what you are looking for. 所以是的,drawable文件夹正是您要的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.