Why don't some xhdpi mobiles display image located in /res/drawable only?

后端 未结 2 1862
时光取名叫无心
时光取名叫无心 2021-02-08 20:14

This is a scenario. There are folders:

  • drawable
  • drawable-ldpi
  • drawable-mdpi
  • drawable-hdpi
  • draawble-xhdpi

An imag

2条回答
  •  一生所求
    2021-02-08 21:02

    I made a project with a drawable that is only in the "res/drawable" folder, tested it on my One X, and confirmed the image is displayed:
    https://github.com/lnanek/Misc/tree/master/TestOneXDrawableFolder

    Layout:

    
        
    
    

    Resources:

    res  
    res/drawable  
    res/drawable/drawableonly.png  
    res/drawable-hdpi  
    res/drawable-hdpi/ic_launcher.png  
    res/drawable-ldpi  
    res/drawable-mdpi  
    res/drawable-mdpi/ic_launcher.png  
    res/drawable-xhdpi  
    res/drawable-xhdpi/ic_launcher.png  
    res/layout  
    res/layout/activity_main.xml  
    res/menu  
    res/menu/activity_main.xml  
    res/values  
    res/values/strings.xml  
    res/values/styles.xml  
    res/values-v11  
    res/values-v11/styles.xml  
    res/values-v14  
    res/values-v14/styles.xml  
    

    You can try to figure out what you are doing different that might be triggering some other behavior. Keep in mind that having a "drawable" folder and a "drawable-mdpi" folder is a little odd, because the drawable folder is mdpi density by default. It may be not be deterministic which of those two will get used. I know using a density specifier does automatically append a -v4 in modern build tools to fix problems with Android 1.5 not understanding these specifiers and handling them correctly, so drawable-mdpi-v4 might be considered to have more specifiers and match in precedence compare to drawable. Both folders have a mdpi density class anyway, however, so keep in mind your drawable from either folder will be scaled up automatically if used from there.

提交回复
热议问题