Context: I am developing an Android application for tablets (landscape) with image resources that has a resolution of 1920x1200. This resolution corresponds to the following screen sizes and densities:
drawable-xlarge-hdpi drawable-large-xhdpi
Problem: If I include all my image resources duplicated in these two folders, the final APK size will be unnecessarily heavy
My bad approach: I tried using Alias ββfor these drawables, as defined here: http://developer.android.com/guide/topics/resources/providing-resources.html#AliasResources
I have an image resource in:
res/drawable-nodpi/image_cmn.png
and two aliases inside the corresponding screen sizes and densities:
res/drawable-xlarge-hdpi/image.xml res/drawable-large-xhdpi/image.xml
image.xml:
<?xml version="1.0" encoding="utf-8"?> <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/image_cmn" />
Of course, when I use my image inside the layout file, I reference the alias:
<ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@drawable/image" />
But, unfortunately, Android does not change the size of the resource for my test tablet (mdpi), and as a result I have more images.
I tried transferring the original png to res / drawable even to res / raw, but the result will be the same as res / drawable-nodpi.
If you move this png to res / drawable-xlarge-hdpi (the same alias xml), the result will be correct, but, of course, that will not solve my problem, I will also have to copy them to res / drawable-large-xhdpi and the apk size will increase .
Does anyone know how to achieve this?