Android 4.0 launcher2 source code analysis-main layout File

Source: Internet
Author: User

A major feature of Android is its desktop notification system. unlike iOS Desktop Management, Android has a desktop system for managing and displaying apps and desktop widgets. Android provides a default desktop Interface

Of course, we can also use third-party desktop applications. The android launcher source code is \ packages \ apps \ launcher2. The main layout file of launcher2 includes res \ Layout-Land \ launcher. xml

, Res \ Layout-port \ launcher. XML, Res \ layout-sw600dp \ launcher. XML, respectively adapted to the horizontal screen, vertical screen and 7-inch tablet. The content is similar. Here we use res \ Layout-port \ launcher. XML as an example.

First, let's look at the structure in launcher. xml:

[HTML]
View plaincopyprint?
  1. <Com. Android. launcher2.draglayer
  2. Xmlns: Android = "http://schemas.android.com/apk/res/android"
  3. Xmlns: launcher = "http://schemas.android.com/apk/res/com.android.launcher"
  4. Android: Id = "@ + ID/drag_layer"
  5. ...
  6. >
  7. <! -- Keep these behind the workspace so that they are not visible when
  8. We go into allapps -->
  9. <Include
  10. Android: Id = "@ + ID/dock_divider"
  11. Layout = "@ layout/workspace_divider"
  12. ...
  13. />
  14. <! -- Paging indicator -->
  15. <Include
  16. Android: Id = "@ + ID/paged_view_indicator"
  17. Layout = "@ layout/scroll_indicator"
  18. ...
  19. />
  20. <! -- The workspace contains 5 screens of cells -->
  21. <Com. Android. launcher2.workspace
  22. Android: Id = "@ + ID/workspace"
  23. ...
  24. >
  25. <! -- Five split screens. cell3 is displayed by default. -->
  26. <Include Android: Id = "@ + ID/cell1" layout = "@ layout/workspace_screen"/>
  27. <Include Android: Id = "@ + ID/cell2" layout = "@ layout/workspace_screen"/>
  28. <Include Android: Id = "@ + ID/cell3" layout = "@ layout/workspace_screen"/>
  29. <Include Android: Id = "@ + ID/cell4" layout = "@ layout/workspace_screen"/>
  30. <Include Android: Id = "@ + ID/cell5" layout = "@ layout/workspace_screen"/>
  31. </COM. Android. launcher2.workspace>
  32. <! -- Search box/Delete box -->
  33. <Include
  34. Android: Id = "@ + ID/qsb_bar"
  35. Layout = "@ layout/qsb_bar"/>
  36. <! -- Display the page of all applications, including the tabs for apps and wightets, And the pages for displaying all apps and real app wightets -->
  37. <Include layout = "@ layout/apps_customize_pane"
  38. Android: Id = "@ + ID/apps_mimize_pane"
  39. ..
  40. />
  41. <! -- Five shortcuts at the bottom of the workspace -->
  42. <Include layout = "@ layout/hotseat"
  43. Android: Id = "@ + ID/hotseat"
  44. ..
  45. />
  46. <! -- The guiding page displayed at startup -->
  47. <Include layout = "@ layout/workspace_cling"
  48. Android: Id = "@ + ID/workspace_cling"
  49. ...
  50. />
  51. <! -- This is the first time a guide page is displayed after all applications -->
  52. <Include layout = "@ layout/folder_cling"
  53. Android: Id = "@ + ID/folder_cling"
  54. ...
  55. />
  56. </COM. Android. launcher2.draglayer>
<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 "... /> <! -- Paging indicator --> <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"...> <! -- Five split screens, 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.works Pace> <! -- Search box/Delete box --> <include Android: Id = "@ + ID/qsb_bar" layout = "@ layout/qsb_bar"/> <! -- Display all application interfaces, including the tabs of apps and wightets, and display the page of all app and the page of the real app wightets --> <include layout = "@ layout/apps_mimize_pane" Android: Id = "@ + ID/apps_customize_pane ".. /> <! -- Five shortcuts at the bottom of the workspace --> <include layout = "@ layout/hotseat" Android: Id = "@ + ID/hotseat".../> <! -- The guiding page displayed at startup --> <include layout = "@ layout/workspace_cling" Android: Id = "@ + ID/workspace_cling".../> <! -- This is the guide page displayed after entering all applications for the first time --> <include layout = "@ layout/folder_cling" Android: Id = "@ + ID/folder_cling "... /> </COM. android. launcher2.draglayer>

Next, let's get to know each view control one by one.

1. The draglayer on the outermost layer is a view control inherited from framlayout, displaying the entire desktop root container. All the controls on the desktop are in the draglayer.

2. ID/dock_divider uses the layout workspace_divider, which is actually an imageview. Is the line between workspace and hotseat.

3. ID/paged_view_indicator: scroll_indicator is used to display a blue horizontal line on ID/dock_divider to indicate the position of the split screen.

4. ID/workspace: The workspace has five workspace_screens, that is, five split screens. Each split screen can be placed with cut and appwidget. The effect is as follows:

5. ID/cell1.. cell5, representing five split screens respectively

6. Search box/Delete box for ID/qsb_bar, and switch as needed

7. ID/apps_customize_pane. The effect is as follows:

8. ID/hotseat is the five shortcut points at the bottom of the main screen.

9. ID/workspace_cling: the animation used for guidance is displayed when launcher2 is run for the first time.


10. ID/folder_cling: the Guiding screen displayed to the user when folder is used for the first time.


In this way, each UI interface and component can be seated, which makes the subsequent analysis clearer.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.