本文介绍了密度合格的可绘制文件夹或drawable-nodpi是否优先?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我为density qualified folder定义了可绘制对象(例如drawable-hdpi),并且还在drawable-nodpi中使用了可绘制对象,那么high density device会在-nodpi上使用-hdpi吗?

If I define drawables for a density qualified folder (eg drawable-hdpi), and also drawables to fall back on in drawable-nodpi, will a high density device use the -hdpi over the -nodpi?

如果我更进一步,并且对-land文件夹也具有相同的设置,该怎么办?

What about if I take it a step further and also have the same setup for -land folders.

推荐答案

我不确定nodpi的优先级是什么,但这绝对不是问题.听起来您误解了nodpi限定词.您不应该使用nodpi作为未在设备的密度存储桶中提供的资产的后备.正确的后备是没有密度限定符(例如drawable/)的文件夹.

I'm not sure what the precedence is for nodpi, but that should never be a problem. It sounds like you are misunderstanding the nodpi qualifier. You should not use nodpi as a fallback for assets that you don't provide at the device's density bucket. The correct fallback is a folder with no density qualifier (e.g. drawable/).

如果系统找不到设备密度的资产(例如,这是ldpi设备,并且您没有drawable-ldpi文件夹),它将退回到没有密度限定符的文件夹,*不是nodpi限定符`.

If the system cannot find an asset at the device's density (e.g. it is an ldpi device and you don't have a drawable-ldpi folder), it will fall back to a folder without a density qualifier, *not the nodpi qualifier`.

当您要指定将用于所有密度的资源并且您不希望Android扩展时,将使用nodpi限定符.其他密度文件夹(例如drawable-xhdpi)中的资产将按实际屏幕尺寸缩放.如果使用nodpi限定词,则您不应在任何其他资源文件夹中提供该资产.

The nodpi qualifier is used when you want to specify a resource that will be used for all densities and that you do not want Android to scale. Assets in the other density folders (e.g. drawable-xhdpi) will be scaled to the actual screen size. If you use the nodpi qualifier, you should not provide that asset in any other resource folders.

还需要注意的是,通过屏幕密度限定符,Android也将优先使用密度较低的资产,而不是不合格的资源.如果您使用的是xhdpi设备,但是只有drawabledrawable-mdpi文件夹,则Android会在mdpi文件夹中检查不合格文件夹之前的资产.

It is also important to note that with screen density qualifiers, Android will also prefer to use a lower density asset over an unqualified resource. If you have an xhdpi device, but you only have a drawable and a drawable-mdpi folder, Android will check for the asset in the mdpi folder before the unqualified folder.

这篇关于密度合格的可绘制文件夹或drawable-nodpi是否优先?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 07:44