天天看點

mipmap和drawable檔案夾的差別

同步釋出在: http://snowdream.github.io/blog/2016/03/02/mipmap-vs-drawable-folders/

現在,通過android studio建立android工程,預設會建立mipmap檔案夾,而不是以前的drawable檔案夾。那麼mipmap和drawable檔案夾到底有什麼差別呢?

mipmap檔案夾下的圖示會通過mipmap紋理技術進行優化。關于mipmap紋理技術的介紹,請參考:mipmap紋理技術簡介

經過查詢官方和第三方資料,得出結論:

mipmap檔案夾下,僅僅建議放啟動圖示/app launcher icons,也就是應用安裝後,會顯示在桌面的那個圖示。而其他的圖檔資源等,還是按照以前方式,放在drawable檔案夾下。

下面再詳細闡述下,得出以上結論的依據:

1.google官方關于mipmap和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. 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.

2.stackoverflow上關于mipmap和drawable的差別

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.

以ic_launcher為例。

1.放在mipmap檔案夾下時,引用方式如下:

2.放在drawable檔案夾下時,引用方式如下:

mipmap紋理技術簡介

mipmap vs drawable folders

google官方關于mipmap和drawable的定位