1. 程式人生 > >mipmap和drawable資料夾的區別

mipmap和drawable資料夾的區別

在Android上建立工程,會預設建立mipmap資料夾。之前在Eclipse上建立的是drawable的資料夾。那麼這兩個有什麼區別呢?
問題:
I’m working with android studio 1.1 Preview 1
我使用android studio 1.1 Preview 1版本工作。
And I noticed that when I create a new project I’m getting next hierarchy:
我注意到當建立新的工程時,得到了下面的目錄層級:
這裡寫圖片描述
mipmap folders for diffrent DPIs, No more diffrent DPIs drawable folders.
4個不同解析度的mipmap資料夾,與不同DPI的drawable資料夾沒啥區別。
Should I put all my resources in the mipmap folders, or just the app icon?
我應該把所有資源都放到mipmap資料夾麼?或者只放應用的圖示?
答案:
The mipmap folders are for placing your app icons in only. Any other drawable assets you use should be placed in the relevant drawable folders as before.
mipmap資料夾只放應用圖示。其他需要使用的drawable資源象之前一樣放到對應的drawable資料夾。
According to this Google blogpost:
根據這篇google的博文:
It’s best practice to place your app icons in mipmap- folders (not the drawable- folders) because they are used at resolutions different from the device’s current density.
應用的啟動圖示最好放到mipmap資料夾(不是drawable資料夾),因為它們用在不同解析度的裝置上。
When referencing the mipmap- folders ensure you are using the following reference:
當引用mipmap資料夾的資源時,需要使用下面的方式:

android:icon="@mipmap/ic_launcher"

結論:
mipmap僅僅用於應用啟動圖示,可以根據不同解析度進行優化。其他的圖示資源,還是要放到drawable資料夾中。

Android 官方解釋[3]:

Note: You should place all launcher icons in the res/mipmap-[density]/ folders, rather than drawable/ folders to ensure launcher apps use the best resolution icon.
注意:你應當將雖有啟動圖示放到res/mipmap-[density]/

資料夾中,而不是drawable/資料夾,來確保啟動圖片使用最好的解析度圖示。