天天看點

android studio 圖檔資源,AndroidStudio 建立圖檔資源

在我們使用AndroidStudio時,項目用到的圖檔資源存放的位置一直都有分歧,有的說放在drawable下,也有的說放在mipmap下,其實google官方已經給出相關介紹:

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.

也就是說一般将APP的icon放在minmap檔案夾下,其他圖檔資源放在drawable檔案夾下。

在建立項目時候,AndroidStudio會自動為我們建立一個drawable檔案夾,我們需要建立針對存放不同尺寸的圖檔的檔案夾,接下來我們再來說說AndroidStudio下建立drawable-hdpi、drawable-mdpi、drawable-xhdpi、drawable-xxhdpi的方法。

1.切換到Project視圖下,找到對應moudle的res檔案夾,然後執行下面步驟,如圖所示:

android studio 圖檔資源,AndroidStudio 建立圖檔資源

1.png

android studio 圖檔資源,AndroidStudio 建立圖檔資源

2.png

android studio 圖檔資源,AndroidStudio 建立圖檔資源

3.png

好了,這樣就完成了~~~~~~~~~~