简体   繁体   English

DRAWABLE-V21 中的 Android drawble-xhdpi、drawable-xxhdpi、drawable-xxxhdpi 子文件夹也适用于 DRAWABLE-V23?

[英]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 .但是,您自己的回答暗示用于v21v24ic.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可绘制的

    • ic_vector.xml ic_vector.xml
    • ic.png (1.0x) ic.png (1.0x)
  • drawable-v21可绘制-v21

    • outterDrawable.xml外部绘图.xml
  • drawable-v23可绘制-v23

    • outterDrawable.xml外部绘图.xml
  • drawable-xhdpi可绘制的 xhdpi

    • ic.png (1.0x) ic.png (1.0x)
  • drawable-xxhdpi可绘制-xxhdpi

    • ic.png (2.0x) ic.png (2.0x)
  • drawable-xxxhdpi可绘制的xxxhdpi

    • ic.png (3.0x) ic.png (3.0x)

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.

相关问题 我是否需要使用所有drawable,drawable-mdpi,drawable-hdpi,drawable-xhdpi,drawable-xxhdpi和drawable-xxxhdpi? - Do I need to use all of drawable, drawable-mdpi, drawable-hdpi, drawable-xhdpi, drawable-xxhdpi & drawable-xxxhdpi? 较新版本的Android Studio和只有两个可绘制目录 - drawable和drawable-v21 - Newer versions of Android Studio and only two drawable directory - drawable and drawable-v21 如果已经有drawable,我们是否还需要Android资源中的drawable文件夹 - hpi,mdpi,xhdpi,xxhdpi,xxxhdpi - Do we still need drawable folder in Android Resources if already have drawable - hpi, mdpi, xhdpi,xxhdpi, xxxhdpi 忽略Android Studio 1.4.0 Drawable-v21项目,转而使用Drawable - Android Studio 1.4.0 Drawable-v21 item ignored in favor of Drawable 可绘制尺寸:LDPI,MDPI,HDPI,XHDPI,XXHDPI,XXXHDPI? - Sizes for drawable: LDPI, MDPI, HDPI, XHDPI, XXHDPI, XXXHDPI? 添加drawable-v21时缺少ImageButton - ImageButton is missing when drawable-v21 is added 使用“文件/新建/矢量资产”选项时,Android Studio 1.4:drawable-v21被忽略 - Android Studio 1.4: drawable-v21 ignored when using “File/New/Vector Asset” option Android.Content.Res.Resources + NotFoundException:文件res / drawable-v21 - Android.Content.Res.Resources+NotFoundException: File res/drawable-v21 我无法创建文件夹drawable-xxxhdpi - I can not create a folder drawable-xxxhdpi android.content.res.Resources$NotFoundException:文件 res/drawable-v21/launch_background.xml - android.content.res.Resources$NotFoundException: File res/drawable-v21/launch_background.xml
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM