Why is the bitmap size smaller than other hdpi folders when put the image into xxxhdpi?

Viewed 73

Here is the code:

imageIv.setImageResources(R.id.icon);

Calculating the image bitmap size:

imageIv.getDrawable().getBitmap();

Here is the result when put the image into different folders:

 |  folder   | bitmap size  |
 |  ----  | ----  |
 | drawable  | 96×96->36 k |
 | xhdpi  | 96×96->36 k |
 | xxhdpi  | 96×96->36 k |
 | xxxhdpi  | 84×84->27 k |

The image origin size is 96×96 px. As the above shown, why the bitmap size is different in xxxhdpi folder from other folders?

1 Answers

I'm assuming those are mipmap images from the res folders found in the project drop menu under the project tab. [assumption based on the naming convention you gave. the xhdpi, xxhdpi, etc]

a screenshot example

there, this is the folder you are talking about. Right?

enter image description here

if you simply want to add an image, right-click on the res folder. from there, select image asset.

image asset example

from there, select the icon type and everything you want. then, once done, android studio would automatically generate different images for different pixel sizes.

The reason it has different image sizes is to have an image for every conventional screen size. This is done so that android doesn't have to scale down or scale up the images because, upscaled or downscaled images don't always look the best. this is mostly important when you are working with vector images. If you haven't changed anything yet in the folder, you'll find the default app icons of different sizes in there which android has generated by default. those are generated using the vector images in the drawable and drawable v26 folder. (vector images have an extension that ends with ".xml"

Related