天天看點

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

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

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

為了一探究竟,翻閱了Android 開發者官網(http://developer.android.com);

找到以下解釋:

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), -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.
           

恕我英語能力不足,無法翻譯;

原文位址:http://developer.android.com/intl/zh-cn/tools/projects/index.html#ApplicationModules

勉強使用工具翻譯,大緻内容如下:
    drawable/
用于圖檔檔案(PNG, JPEG , or GIF), 圖檔檔案 和 XML檔案;
    mipmap/
用于App Launcher圖示;
           

其他官網相關閱讀位址:

http://developer.android.com/intl/zh-cn/tools/projects/index.html#mipmap

http://developer.android.com/intl/zh-cn/guide/practices/screens_support.html#support

補充閱讀:

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

比如:

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

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