I am writing an app that has a lot of images (about 200) which are different items that you can select and order. So far I have been using Glide to load the images from file. To support different resolutions, I made a image of the item with my smartphone and converted them into the 5 different Android resolutions in the folders drawable-mdpi, drawable-hdpi, drawable-xhdpi, drawable-xxhdpi and drawable-xxxhdpi.
The problem is that the original image has as size of 4,2 MB and all 5 images together just for one item for the different resolutions have a size of 18 MB (0,7 MB, 1,5 MB, 2,5 MB, 5,6 MB and 7,8 MB). If I now do this for 200 images, I will have to store 3,6 GB of images within the app. Thus, the size of the app would be extremely big.
So I would like to know what is a good way of dealing with so many images in an app? Is there a way to include multiple images for different resolutions while still having an app whose size is not enormous?
Follow the following steps:-
Set the quality percentage according to your desire
See the difference of image sizes
In this way, quality will not be much compromised & large size problem will be solved.
loadGlide(R.drawable.testing, imageView)
Call this function from everywhere
private fun loadGlide(resId: Int, imageView: ImageView) {
Glide.with(context).load(resId).with(imageView)
}
public static void loadGlide(int resId, ImageView imageView) {
Glide.with(getContext()).load(resId).with(imageView);
}