AndroidStudio學習記錄---初觸AndroidStudio

第一個AndroidStudio工程

AndroidStudio已經問世三個年頭了,各方面功能也已經完備,版本也來到了2.2預覽版,我選用的是2.1正式版。決定好好學習掌握AS,特此記錄。

  1. 首先新建工程,輸入工程名和主包名和存儲路徑。
  2. 點擊可查看目前各個版本的覆蓋情況,視情況選擇對應的版本。
    這裏寫圖片描述
  3. 接下來一直Next即可,最後Finish完成工程的創建。

    有一個問題需要大家注意,在AS中,Project相當於Eclipse裏的WorkSpace,而AS裏的Module相當於我們之前Eclipse裏的Project的概念,最開始接觸的時候我也有點暈,而且竟然找不到在哪裏刪除工程,真是尷尬,在這裏提示一下:File->Project Structure 在左邊欄下面Modules裏就是當前Project裏的所有工程了,選中你要刪除的,點擊左側邊欄最上面的減號即可刪除。

  4. 接下來跑起來我們的程序肯定是HelloAndroidStdio,沒什麼好說的。

  5. 只寫一句話就完事,那我們不是太弱了。起碼也加一張圖啊,無圖無真相啊。那麼問題又來了,工程目錄下怎麼就一個drawable文件夾啊,不區分不同分辨率了?咦,mipmap又是什麼東東,怎麼這個文件裏有不同分辨率的顯示。難道換了?既然他的圖標能放,我也試試。這裏在調用得改成”@mipmap/ur_image_name”。
    這裏寫圖片描述
    這裏測試可用,那麼drawable還能用嗎,當然是可以的。

這裏扒一扒兩者之間的區別吧:
http://blog.csdn.net/angcyo/article/details/46358729

main/res/ 在這個目錄下存放應用程序的資源,例如drawable文件,layout佈局文件以及鍵值等。
Contains application resources, such as drawable files, layout files, and string values in the following directories.
drawable/ 存放圖片,點9圖,以及自定義的形狀,自己設置的狀態,選擇器等。
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/ 存放app的啓動圖標,根據系統分辨率不同指定不同的文件夾,和drawable-mdpi、drawable-hdpi、drawable-xhdpi這些差不多。
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.

使用方法的區別:

  1. drawable

    android:icon=”@drawable/ic_launcher”
    R.drawable.ic_launcher

  2. mipmap

    android:icon=”@mipmap/ic_launcher”
    R.mipmap.ic_launcher

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章