[英]Android drawble-xhdpi, drawable-xxhdpi, drawable-xxxhdpi subfolders inside DRAWABLE-V21 also for DRAWABLE-V23?
I know it is not possible to add subfolders inside drawable-v21.我知道不可能在 drawable-v21 中添加子文件夹。 But how would I accomplish android to take different sizes of resources inside drawable-v21.但是我将如何完成 android 在 drawable-v21 中获取不同大小的资源。 For example for: drawable-xhdpi, drawable-xxhdpi, drawable-xxxhdpi.例如:drawable-xhdpi、drawable-xxhdpi、drawable-xxxhdpi。
I need this behaviour - (ic.png should be the same image with different pixel sizes)我需要这种行为 - (ic.png 应该是具有不同像素大小的同一图像)
drawable-v21可绘制-v21
drawable-xhdpi可绘制的 xhdpi
ic.png ic.png
drawable-xxhdpi可绘制-xxhdpi
ic.png ic.png
drawable-xxxhdpi可绘制的xxxhdpi
ic.png ic.png
drawable-v23可绘制-v23
drawable-xhdpi可绘制的 xhdpi
ic.png ic.png
drawable-xxhdpi可绘制-xxhdpi
ic.png ic.png
drawable-xxxhdpi可绘制的xxxhdpi
ic.png ic.png
How can I accomplish this?我怎样才能做到这一点?
Resource qualifiers can be used in combination with each other (though there is a specific order that must be followed when combining them).资源限定符可以相互组合使用(尽管在组合它们时必须遵循特定的顺序)。 All qualifiers and their precedence order are listed here: https://developer.android.com/guide/topics/resources/providing-resources#AlternativeResources此处列出了所有限定符及其优先顺序: https://developer.android.com/guide/topics/resources/providing-resources#AlternativeResources
You could, therefore, use a directory structure like this:因此,您可以使用如下目录结构:
res/
drawable-xhdpi-v21/
ic.png
drawable-xhdpi-v24/
ic.png
drawable-xxhdpi-v21/
ic.png
drawable-xxhdpi-v24/
ic.png
Your own answer, however, implies that there is no difference between the ic.png
file used for v21
and v24
.但是,您自己的回答暗示用于v21
和v24
的ic.png
文件之间没有区别。 In this case, there's no need to specify the version at all:在这种情况下,根本不需要指定版本:
res/
drawable-xhdpi/
ic.png
drawable-xxhdpi/
ic.png
UPDATE:更新:
I realized I can solve my problem this way:我意识到我可以这样解决我的问题:
drawable可绘制的
drawable-v21可绘制-v21
drawable-v23可绘制-v23
drawable-xhdpi可绘制的 xhdpi
drawable-xxhdpi可绘制-xxhdpi
drawable-xxxhdpi可绘制的xxxhdpi
Where outterDrawable (drawable-v21) looks like this: outterDrawable (drawable-v21) 看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap android:src="@drawable/ic" android:gravity="center" />
</item>
</layer-list>
Where outterDrawable (drawable-v23) looks like this: outterDrawable (drawable-v23) 看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:src="@drawable/ic_vector" android:gravity="center"/>
</layer-list>
Let me know is there is a different solution.让我知道是否有不同的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.