On iOS, you can specify @2x images that will be used in places where the pixel density (UIScreen scale) is greater than 1. You still refer to logical pixels, but the images will display using the actual physical pixels (which are usual 4x the logical pixels).
On Android, it seems like using dp to specify dimensions has a similar effect. For example, a layout such as the following
<TextView
android:layout_width="50dp"
android:layout_height="25dp"
android:id="@+id/MessageTextView"
android:background="@drawable/messageBackground" />
If the image messageBackground is a higher resolution than 50x25, the platform scales it appropriately when displayed on a screen with higher density, using the additional pixel information to fill the increased pixels. (At least that is how it appears to me).
My question, however, relates to nine patched images. These are the images that stretch based on the actual size that they are displayed over.
nine patched images I have not been able to figure out how to make them 'scale up' on higher density screens. As you'd expect, the expandle portion of the nine patch stretches to make an image larger. But the 'fixed' portions of the nine patch are just displayed using dp pixels, not actual pixels.
Is there a way to use a higher res image with nine patch, such that the 'fixed' portions of the image display at the full resolution of the device? I don't want the higher res version to just appear larger, I want it to display it's natural size using all the available pixels for the best possible image.
Is there a way to use a higher res image with nine patch, such that the 'fixed' portions of the image display at the full resolution of the device?
Yes. See Providing Resources and Supporting Multiple Screens documentation on the Android developers site.
You need to create your resources at multiple resolutions, then you simply drop them into the appropriate drawable folders for that density bucket.
Essentially, the drawables-mdpi
folder is the one to use for your standard 1x resources. drawables-xhdpi
is your 2x. You probably want to provide your drawables at mdpi, hdpi, xhdpi, and xxhdpi to provide appropriate quality resources for the vast majority of Android devices.