When should I use mipmaps?

Asked

Viewed 564 times

4

After Google started adding Mipmaps I ended up not researching exactly why. Even with this addition, it does not prevent anything from using the Drawable as 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 don’t understand exactly what the real meaning of having these changes was. In old applications still remain drawable and apparently they are unchanged and continue with the same purpose.

In the project

inserir a descrição da imagem aqui I did a little research and found some answers, but not so satisfying.

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

  • 1

    I once had a problem with a png with transparency, which was in the folder drawable, She did not press the phone (in the editor appeared).. After investigating I saw that I had to change to the mipmap folder, I just moved and it worked, but I also do not know why, so it goes +1 to question..

1 answer

4


The difference between the folder drawable and the mipmap is that when the application is installed on a device with a certain screen density, the Resources the other densities are discarded from the first and kept in the second.

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

The reason is that some devices feature the "Launcher icons" up to about 25% if there is a icon in a higher resolution it will be using instead of being made a magnification, thus maintaining the image quality.

Thus, the folder mipmap should be used primarily for "Launcher icons".

However, from Android 4.2, it is possible to use a mipmap as source of objects Bitmap and, after Android 4.3, also in objects Bitmapdrawable, allowing image quality to be maintained, for example during an animation involving reductions/magnifications.
Having the various images in the folder mipmap and using the methods setHasMipMap() and hasMipMap(), Android will be able to choose the one that best suits each frame of animation.

Source:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.