Reputation: 402
I am making an android project with AndroidStudio and I have a problem with the physical size of the images that I am using.
Basically I have 15 activities and all of them have different .png
files for their background and their buttons. These pictures are in FullHD(1080x1920). I created different "variations" for each picture using the plugin Android Drawable Importer
which takes a picture and "redraws" it for different screen densities (ldpi, mdpi, hdpi, xhdpi, xxhdpi and xxxhdpi). So far so good.
But doing this I am making for each of my pictures (96 in total) 5 copies. And the total size of the resulting pictures in all the drawable directories is around 100MB which make the .apk
file that big.
So my question is: Is there a way to optimize this size or some other better approach?
I have read Supporting multiple screens article which tells me to do what I am doing, but id doesn't consider the resulting size of the .apk file and respectively the size of the app when it is installed on the phone.
Upvotes: 1
Views: 277
Reputation: 402
Actually the solution in my case was really easy. I was using .png
files for my background images which took a lot of the space and it wasn't really necessary to do so, because I don't need my backgrounds to be transparent. So I converted the background files to .jpg
and left all my other images for buttons in .png
and the size of the .apk
became 16MB. Which is something like 8-9 times smaller than my inital .apk
.
Upvotes: 1
Reputation: 464
try to use svg http://developer.android.com/tools/help/vector-asset-studio.html
With existing method: use hdpi images if you are using for screens till 5" else use xdpi for 7" if more than that use xhdpi. If you are targeting only devices with screen less than 5" then stick to hdpi itself, it will serve the purpose.
Upvotes: 1
Reputation: 748
Can't you make the app to download (only once and cache/store it in SD-card) the required images (large ones, maybe background images, if not all) once depending on the screen size or resolution from the server.
I don't think using that many images and that many size is a good idea.
IMHO if the user is using a device of screen resolution of xxxhdpi, I can assume that he can at-least afford to download those images atleast once! Same apply for other users also!
If the above solution is not applicable for you, I can suggest use those images by compressing it. There are some software for that. Or you can use online site: https://tinypng.com to compress the image.
Upvotes: 0