Reputation: 779
I know it is not possible to add subfolders inside drawable-v21. But how would I accomplish android to take different sizes of resources inside drawable-v21. For example for: drawable-xhdpi, drawable-xxhdpi, drawable-xxxhdpi.
I need this behaviour - (ic.png should be the same image with different pixel sizes)
drawable-v21
drawable-xhdpi
ic.png
drawable-xxhdpi
ic.png
drawable-xxxhdpi
ic.png
drawable-v23
drawable-xhdpi
ic.png
drawable-xxhdpi
ic.png
drawable-xxxhdpi
ic.png
How can I accomplish this?
Upvotes: 0
Views: 292
Reputation: 779
UPDATE:
I realized I can solve my problem this way:
drawable
drawable-v21
drawable-v23
drawable-xhdpi
drawable-xxhdpi
drawable-xxxhdpi
Where outterDrawable (drawable-v21) looks like this:
<?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:
<?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.
Upvotes: 0
Reputation: 54204
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
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
. In this case, there's no need to specify the version at all:
res/
drawable-xhdpi/
ic.png
drawable-xxhdpi/
ic.png
Upvotes: 1