Reputation: 87
I know there is a need for xxxhdpi for icons. However, should we make xxxhdpi assets for general images? The gap seems to be insignificant. I am testing on 2 1440 x 2560 phones. However, one is 5.5 inches and is xxxhdpi (3.5 density), the other is 5.7 inches and is xxhdpi (3.15 density). Does 0.2 difference inches really deserve 1.3 times larger assets? The only reason, I could image it being usefull, is on UHD phones.
Upvotes: 1
Views: 2980
Reputation: 10517
For any other images that aren't icon you have to still use the dpi specific packages... even if you don't.
Here is the documentation https://developer.android.com/guide/practices/screens_support.html#terms
I have found 2 usefull methods.
With this and the doc you can know your screen density https://play.google.com/store/apps/details?id=com.sturnus.screeninfo
Here is a calculator https://chrome.google.com/webstore/detail/dpi-calculator/dldofgjemhkpilajnlenfijjpkabilcg
This also work if you want a full screen images, using the app I have mentioned you can see the width and height of the screen.
2.- Use a View as reference. By example, set width and heigh of an ImageView in dp, once you found the correct size use a calculator to conver it to px and create every image
Here is the calculator http://labs.rampinteractive.co.uk/android_dp_px_calculator/
I don't recommend to use the Android Studio assistant, is not 100% reliable.
If your min and max API allowed use vectors, thar assistant is very good. Beware retrocompatibility doen't support drawable_left for vectors.
Here is a post about it https://android-developers.googleblog.com/2016/02/android-support-library-232.html?m=1
If you only want to use 1 image per asset then use no-dpi or any-dpi. Android OS will by default try to scale images, thar behaviour will be prevent in no-dpi directory.
Upvotes: 2
Reputation: 28238
Where I put my image assets vary. In some cases it is useful to have it in xxxhdpi because it ended up being too big when rendered, or in the lowest density when it ended up too small (based on mdpi).
Where you place the image assets is something you need to figure out yourself. Some you want in xxxhdpi, some you want in mdpi and some you want to create one version of for each density. There is no "one answer" to this, it is all about any given scenario. This texture may be good to have in hdpi, this in xxhdpi, and this one in assets and this fourth in idpi.
If you target the higher resolution devices and want those to get the best experience possible, yes you should use xxxhdpi for most images. Note that this means a lot of scaling on lower densities, which may result in low image quality. In those cases you may want to consider adding a second image scaled to mdpi (or hdpi) to prevent the extreme cases where the image gets very blurry.
The best practise is most likely adding one texture for each density to ensure quality in the resources.
If you use xxxhdpi or not is something you need to see on your resources. Some you want in xxxhdpi, some you want in mdpi.
However, one is 5.5 inches and is xxxhdpi (3.5 density), the other is 5.7 inches and is xxhdpi (3.15 density). Does 0.2 difference inches really deserve 1.3 times larger assets?
Given 1920x1080, the bigger screen has lower pixel density when you go up in size. 5.5 being xxxhdpi (the size isn't 1920x1080 I assume, I used that as an example) and 5.7 being xxhdpi makes sense when the size (in pixels) are fixed. And you got it wrong when it comes to the scales. Rotwang's comment:
xxxhdpi is 4x mdpi. And xxhdpi is 2x mdpi. Therefore, 1px on mdpi scales to 4px on xxxhdpi
Keep that in mind when you create your images
Upvotes: 3