1. 程式人生 > >Android Studio(AS)-->drawable與mipmap (官網解釋)

Android Studio(AS)-->drawable與mipmap (官網解釋)

閱讀前提: 你需要提前瞭解 drawable 和 mipmap 是什麼;

使用Android Studio IDE, 新建Android專案的時候,程式(APP)啟動圖示ic_launcher.png,沒有在之前的老地方(drawable目錄),而是出現在mipmap目錄結構下;

找到以下解釋:

main/res/
    Contains application resources, such as drawable files, layout files, and string                  values in the following directories. See Application Resources for
more information. drawable/ For bitmap files (PNG, JPEG, or GIF), 9-Patch image files, and XML files that describe Drawable shapes or Drawable objects that contain multiple states (normal, pressed, or focused). See the Drawable resource type. mipmap/ For app launcher icons. The Android system
retains the resources in this folder (and density-specific folders such as mipmap-xxxhdpi) regardless of the screen resolution of the device where your app is installed. This behavior allows launcher apps to pick the best resolution icon for your app to display on the home screen. For more information
about using the mipmap folders, see Managing Launcher Icons as mipmap Resources.
勉強使用工具翻譯,大致內容如下:
    drawable/
用於圖片檔案(PNG, JPEG , or GIF), .9圖片檔案 和 XML檔案;
    mipmap/
用於App Launcher圖示;

補充閱讀:
兩者使用上沒有任何區別,你把它當drawable用就好了。唯一的區別就是用mipmap系統會在縮放上提供一定的效能優化。

比如:
Nexus 6 有 493 ppi,它剛好在 xxhdpi和xxxhdpi之間,所以顯示的時候需要對xxxhdpi的資源進行縮小,如果你用了mipmap-xxxhdpi,那麼這裡會對sclae有一個優化,效能更好,佔用記憶體更少。所以現在官方推薦使用mipmap.

至此: 文章就結束了,如有疑問: QQ群:274306954 歡迎您的加入.