本文來自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中的結構:
[html] view plain copy <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> <!-- 搜尋方塊/刪除框 -->