When should I use mipmaps?

4

After Google started adding Mipmaps I did not exactly search for why. Even with this addition, it does not prevent anything from using Drawable as it was before.

Before

res/
    drawable-mdpi/ic_launcher.png (48x48 pixels)
    drawable-hdpi/ic_launcher.png (72x72)
    drawable-xhdpi/ic_launcher.png (96x96)
    drawable-xxhdpi/ic_launcher.png (144x144)
    drawable-xxxhdpi/ic_launcher.png (192x192)

Today

res/
    drawable/
    mipmap-mdpi/ic_launcher.png (48x48 pixels)
    mipmap-hdpi/ic_launcher.png (72x72)
    mipmap-xhdpi/ic_launcher.png (96x96)
    mipmap-xxhdpi/ic_launcher.png (144x144)
    mipmap-xxxhdpi/ic_launcher.png (192x192)

Even seeing some questions, I still do not understand exactly what the real meaning of having these changes was. In old applications they still remain drawable and apparently do not undergo any changes and continue with the same purpose.

In the project

Ididalittleresearchandfoundsomeanswers,butnotquitesosatisfying.

What's the real difference between Mipmap and Drawable ? When should I use Mipmap ? Is there any limitation if I use Drawable ?

    
asked by anonymous 22.09.2016 / 20:58

1 answer

4

The difference between the drawable folder and mipmap folder is that when the application is installed on a device with a certain density of screen, the resources in the folder referring to the other densities are discarded of the first and maintained in the second one.

But then, you ask, why do I need to keep resources for the other densities?

The reason is that some devices have the "launcher icons" increased by up to 25%, if there is a icon at a higher resolution it will be using instead of enlargement, thus maintaining image quality.

So the mipmap folder should be used primarily for the "launcher icons" folder.

However, from Android 4.2, you can use a mipmap as source of Bitmap objects and, after Android 4.3, also in BitmapDrawable objects, allowing you to maintain image quality, for example, during an animation involving reductions / enlargements. Having the various images in the mipmap folder and using the methods setHasMipMap () and hasMipMap () , Android may choose the one that best suits each frame of the animation.

Source:

23.09.2016 / 00:50