標籤:drag nta target 技術 value imageview rtc -- div
本文來自http://blog.csdn.net/chenshaoyang0011
Android系統的一大特色是它擁有的案頭通知系統,不同於IOS的案頭管理,Android有一個案頭系統用於管理和展示APP以及案頭Widget等。
Android提供一個預設的案頭應用,當然我們也可以使用第三方的案頭應用。Android的Launcher的源碼在 \packages\apps\Launcher2。
Launcher2的主布局檔案包括res\layout-land\launcher.xml
, res\layout-port\launcher.xml , res\layout-sw600dp\launcher.xml ,分別適配橫屏,豎屏和7寸平板。內容大同小異,這裡就以res\layout-port\launcher.xml的為例。
首先讓我們看看launcher.xml中的結構:
- <com.android.launcher2.DragLayer
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
- android:id="@+id/drag_layer"
- ...
- >
-
- <!-- Keep these behind the workspace so that they are not visible when
- we go into AllApps -->
- <include
- android:id="@+id/dock_divider"
- layout="@layout/workspace_divider"
- ...
- />
-
- <!-- 分頁指標 -->
- <include
- android:id="@+id/paged_view_indicator"
- layout="@layout/scroll_indicator"
- ...
- />
-
- <!-- The workspace contains 5 screens of cells -->
- <com.android.launcher2.Workspace
- android:id="@+id/workspace"
- ...
- >
-
- <!-- 五個分屏,預設顯示cell3 -->
- <include android:id="@+id/cell1" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell2" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell3" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell4" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell5" layout="@layout/workspace_screen" />
- </com.android.launcher2.Workspace>
-
- <!-- 搜尋方塊/刪除框 -->
- <include
- android:id="@+id/qsb_bar"
- layout="@layout/qsb_bar" />
-
- <!-- 顯示具體全部應用的介面,包括APPS、WIGHETS的tab標籤,以及顯示ALL APP的頁面和現實APP WIGHETS的頁面 -->
- <include layout="@layout/apps_customize_pane"
- android:id="@+id/apps_customize_pane"
- ..
- />
-
- <!-- WorkSpace最下面的五個快捷位置 -->
- <include layout="@layout/hotseat"
- android:id="@+id/hotseat"
- ..
- />
-
- <!-- 剛啟動的時候顯示的指導頁 -->
- <include layout="@layout/workspace_cling"
- android:id="@+id/workspace_cling"
- ...
- />
-
- <!-- 是第一次進入全部應用之後顯示的指導頁 -->
- <include layout="@layout/folder_cling"
- android:id="@+id/folder_cling"
- ...
- />
- </com.android.launcher2.DragLayer>
接著我們來一一認識每一個View控制項。
1、最外層的DragLayer,是一個繼承自FramLayout的View控制項,顯示的就是整個案頭根容器。案頭的所有控制項都是位於DragLayer中。
2、id/dock_divider,使用了布局workspace_divider,其實就是一個ImageView。是Workspace與Hotseat之間的分割線。
3、id/paged_view_indicator,使用了布局scroll_indicator,顯示效果是在id/dock_divider上顯示一條淡藍色的橫線,來指示當分屏所處的位置
4、id/workspace ,工作空間擁有五個workspace_screen,即有五個分屏,每個分屏都可以放置shortcut和AppWidget,效果如下:
5、id/cell1..cell5 ,分別代表五個分屏
6、id/qsb_bar 搜尋方塊/刪除框,根據需要進行切換
7、id/apps_customize_pane,效果如下
8、id/hotseat 即主畫面下方的五個快捷位置
9、id/workspace_cling當第一次運行Launcher2時,會顯示的用於指導的動畫,以後不再顯示
10、id/folder_cling,第一次使用Folder時,展示給使用者的指導畫面。
這樣,我們已經可以使每個UI介面及組件都對號入座,這會使接下來分析的時候更加清晰。
Android 4.0 Launcher2源碼分析——主布局檔案(轉)