Resources for drawable-xlarge-mdpi AND drawable-sw600dp-mdpi without duplication
android
Solution
Is there a similar approach for drawables?
It should work exactly as it does for layouts
put `png` resources into the default folder
res/drawable/largescreen.png
res/drawable/smallscreen.png
create `.xml` resources that refer to the `png`s
res/drawable/image.xml
res/drawable-xlarge-mdpi/image.xml
res/drawable-sw600dp-mdpi/image.xml
where `image.xml` is something like (documentation)
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/largescreen" />
and then use the XML resource as you would use the png directly
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/image" />
Problem
I want to provide the same image resources/drawables to both drawable-xlarge-mdpi AND drawable-sw600dp-mdpi. It seems the only way I can do this is by creating two folders under res/ and copying the same set of resources into each folder. With layouts we can do aliasing. I.e. creating a file called layout.xml in the values folder with specific qualifiers and adding items to point to a single layout file for both qualifiers: - values-xlarge\values.xml - values-sw600dp\values.xml The contents of both files would be something like: ``` <?xml version="1.0" encoding="utf-8"?> <resources> <item name="activity_shows" type="layout">@layout/activity_shows_tablet</item> </resources> ``` (Devices matching xlarge or devices matching sw600dp would now use activity_shows_tablet.xml as the layout file for "activity_shows") Is there a similar approach for drawables?