mipmap和drawable使用

.來看一段話
Here is my two cents in trying to explain the difference. There are two cases you deal with when working with images in Android:
You want to load an image for your device density and you are going to use it “as is”, without changing its actual size.
In this case you should work with drawables and Android will give you the best fitting image.
You want to load an image for your device density, but this image is going to be scaled up or down.
For instance this is needed when you want to show a bigger launcher icon, or you have an animation,
which increases image’s size. In such cases, to ensure best image quality,
you should put your image into mipmap folder. What Android will do is,
it will try to pick up the image from a higher density bucket instead of
scaling it up. This will increase sharpness (quality) of the image.
Thus, the rule of thumb to decide where to put your image into would be:
Launcher icons always go into mipmap folder.
Images, which are often scaled up (or extremely scaled down) and whose quality is critical for the app,
go into mipmap folder as well.
All other images are usual drawables.

.意思就是當圖片不需要改變尺寸的時候,圖片放drawable,如果圖片需要改變尺寸,比如動畫裏面需要放大,就要放到mipmap,這時候如果圖片放到,會自動加載更高尺寸的目錄裏面的圖片,從而避免失真.
一般來說,mipmap僅僅用於應用啓動圖標,可以根據不同分辨率進行優化。其他的圖標資源,還是要放到drawable文件夾中。

.爲什麼我們應該使用mipmap來啓動應用程序啓動器圖標?

設備具有不同的分辨率,所以啓動器應用程序顯示不同分辨率的圖標。資源優化技術有時會爲未使用的屏幕密度移除資源,並且當啓動器應用程序必須升級顯示器的較低分辨率圖標時,它可能看起來模糊不清。爲了避免這個問題,應用程序應該爲應用程序啓動器圖標使用mipmap可繪製文件夾。在Android系統從未條這一資源,並確保啓動應用程序可以選擇與顯示器的最佳分辨率的圖標。

它可以確保啓動器應用程序通過將啓動器圖標的所有密度移動到密度特定的res / mipmap /文件夾(例如res / mipmap-mdpi /和res / mipmap-xxxhdpi /)來爲您的應用程序顯示高分辨率圖標。應用程序使用mipmap /文件夾代替啓動圖標的可繪製/文件夾。對於xxhpdi啓動器圖標,請務必添加更高分辨率的xxxhdpi版本的圖標,以增強高分辨率設備上圖標的視覺體驗。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章