As you know Android applications have different DPIs and also in the Android applications we can add drawable
s with diffrent DPIs in diffrent ldpi
, mdpi
, hdpi
and xhdpi
folders.
The question is that when we want to support all DPIs we should add the icons with all different sizes or just with the biggest one?
I mean for example suppose that I have one action bar item with icon. Whether I should add the icon of this action bar item with 24x24(in drawable-mdpi folder),36x36 (in drawble-hdpi folder),48x48 (in drawable-xhdpi folder),.....
Or I just need to add one icon with size 96x96 in xxxhdpi
folder and android will set the icon for other DPIs with good quality?
TLDR see the bold below
Different density folders were added later on for Android which means that...
If you wanted to be lazy and just add one asset the best choice would probably be the HDPI asset if your min app target < 8 and XHDPI if its >= 8. This is because the system will scale the resource up and down, but you would still want to start off with the highest resolution possible.
If you want to have complete control over how the assets are scaled then you can by all means provide your own for all / some of the densitys. In practise I generally provide HDPI / XHDPI as above and give all the resource buckets for things like logos / AB icons / App icons etc. I generally find the auto scaling to be pretty good and work for most situations, but will occasionally have to supply and extra LD/MD asset if its a small asset / contains small text etc. Plus if i duplicated all assets for things like XXXHDPI I would get pretty good apk bloat.
You can also use IDEs built in tools to add a single asset for many densitys at once. In Android Studio 0.6 this is File->New->Image Asset and a wizard will appear.
I have never noticed or heard of any perfomance impact of allowing Android to scale assets automatically - presumably this is done in hardware.
It may not look great when auto scaling down to LDPI say so you can optionally provide your own scaled assets for all other densities.
Taken from the link below
List taken from this dev link for more info.
This is the approach I have used on many apps in my professional career including ones for Google & the BBC and not had issues.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With