I am struggling with a rather trivial task in an Android domain with multiple screens.
What am i trying to achieve
A layout that matches the width of the screen, with a background with nine patches that changes (only horizontally, since there is always enough vertical space). Here is a dummy image:
My goal is to display the image with the highest possible resolution, depending on the screen resolution, using a set of different sizes, for example. 320x45, 480x67, 600x87, 720x101, without any scaling. I hope for a non-software solution.
An example with the above image sizes:
- 3.7 "Nexus One (480 x 800) - A 480x67 image will look best.
- 4.7 "Galaxy Nexus (720 x 1280) - The image is 720x101.
- 4.7 "Nexus 4 (768 x 1280) - again the image is 720x101, stretching to the full width of 768 px and becoming 768x101.
Question
The whole distribution of Android resources revolves around dp(independent of pixel density) when in fact I want to display an image based on the actual available pixels.
If I selected a 480x67 image for res / drawable-mdpi and 600x87 for res / drawable-hdpi, then the image will display correctly on the 5.4 "480x800 display , i.e. the mdpi display. However, 4" 480x800 displays meet the hdpi criteria and the system will assign a 600x87 image, t fits the screen .
smallestWidth, -, . , 3,7 "480 x 800 (hdpi) drawable-sw320dp, drawable-sw480dp.
, ? ?
!