天天看點

android idea(studio)下目錄結構學習

在用 idea 建立項目的時候,我們會看到一堆的目錄,增加了很多eclipse裡面不具備的目錄,而且目錄結構也改變了。一般我們之關注特定的一些目錄,而忽略的其他,當出問題的時候基本會茫然若失不知道如何解決,是以特地學習下目錄結構。

Project下的視圖

引用位址:https://github.com/siyehua/Adnroid-Notes/tree/master/Android%20Studio/Directory%20Info

android idea(studio)下目錄結構學習

圖檔中的連結 Gralde介紹:http://stormzhang.com/devtools/2014/12/18/android-studio-tutorial4/

GIT/github使用:http://www.worldhello.net/gotgithub/

.gitignore檔案說明:http://www.html-js.com/article/2030

module 說明:

Android Studio 的 project 相當于 Eclipse 的 workspace

Android Studio 的 module 相當于 Eclipse 的 project

1.gitignore寫法

Android的Module推薦這麼寫.gitignore檔案

/build
*.iml
           

Android的項目.gitignore檔案推薦這麼寫

# Built application files
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log
           

2. .gradle目錄,.idea目錄

android idea(studio)下目錄結構學習

這些都是項目建立的時候自動生成的,一般情況不做修改,不需要納入項目源代碼管理中。

3. module下build 目錄

android idea(studio)下目錄結構學習

我們編譯最終生成的apk就在build/outputs/apk目錄下,裡面包含了app-debug.apk, app-debug-unaligned.apk,app-release-unaligned.apk三種apk。

4. module下 src 目錄

android idea(studio)下目錄結構學習

drawable 和 mipmap 的差別

使用上沒有任何差別,你把它當drawable用就好了。

但是用mipmap系統會在縮放上提供一定的性能優化。

https://segmentfault.com/q/1010000002603418 學習資料

mipmap 和 drawable 的差別摘錄:

Mipmapping for drawables

Using a mipmap as the source for your bitmap or drawable is a simple way to provide a quality image and various image scales, which can be particularly useful if you expect your image to be scaled during an animation.

Android 4.2 (API level 17) added support for mipmaps in the Bitmap class—Android swaps the mip images in your Bitmap when you’ve supplied a mipmap source and have enabled setHasMipMap(). Now in Android 4.3, you can enable mipmaps for a BitmapDrawable object as well, by providing a mipmap asset and setting the android:mipMap attribute in a bitmap resource file or by calling hasMipMap().

Android 在 API level 17 加入了 mipmap 技術,對 bitmap 圖檔的渲染支援 mipmap 技術,來提高渲染的速度和品質。

mipmap 是一種很早就有的技術了,翻譯過來就是紋理映射技術。android 中的 mipmap 技術主要為了應對圖檔大小縮放的處理,在android 中我們提供一個 bitmap 圖檔,由于應用的需要(比如縮放動畫),可能對這個 bitmap 進行各種比例的縮小,為了提高縮小的速度和圖檔的品質,android 通過 mipmap 技術提前對按縮小層級生成圖檔預先存儲在記憶體中,這樣就提高了圖檔渲染的速度和品質。

api 中通過 Bitmap 的 public final void setHasMipMap (boolean hasMipMap) 方法可以讓系統渲染器嘗試開啟 Bitmap 的 mipmap 技術。但是這個方法隻能建議系統開啟這個功能,至于是否正真開啟,還是由系統決定。

res 目錄下面 mipmap 和 drawable 的差別也就是上面這個設定是否開啟的差別。mipmap 目錄下的圖檔預設 setHasMipMap 為 true,drawable 預設 setHasMipMap 為 false。