Android 4.0 Launcher源码分析1-概念分析

1.工具和文件-过查看Launcher.xml 和使用hierarchyviewer布局查看工具

可以看到整个桌面包含的元素,最上面是Google的搜索框,下面是一个时钟插件,然后是图标,再有就是一个分隔线,最后是dock。请注意,桌面程序其实并不包含桌面壁纸桌面壁纸其实是由 WallpaperManagerService来提供,整个桌面其实是叠加在整个桌面壁纸上的另外一个层。




<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" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
 
    <!-- Keep these behind the workspace so that they are not visible when 
         we go into AllApps --> 
    <include //dock_divider,包含了一ImageView,其实dock_divider就是dock区域上面的那条直线。
        android:id="@+id/dock_divider" 
        layout="@layout/workspace_divider" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginBottom="@dimen/button_bar_height" 
        android:layout_gravity="bottom"  /> 
    <include //paged_view_indicator,同样它包含了scroll_indicator.xml,其中包含了一个ImageView,显示的是一个.9的png文件。实际上就是当Launcher滚动翻页的时候,那个淡蓝色的页面指示条。
        android:id="@+id/paged_view_indicator" 
        layout="@layout/scroll_indicator" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="bottom" 
        android:layout_marginBottom="@dimen/button_bar_height"  /> 
 
    <!-- The workspace contains 5 screens of cells --> 
    <com.android.launcher2.Workspace
//
整个workspace由5个workspace_screen组成,而每个workspace_screen包含了一个CellLayout,这是一个自定义控件,继承自ViewGroup,所以它算是一个用来布局的控件,在这里主要用来承载我们每页的桌面图标、widget和文件夹。

        android:id="@+id/workspace" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:paddingTop="@dimen/qsb_bar_height_inset" 
        android:paddingBottom="@dimen/button_bar_height" 
        launcher:defaultScreen="2" 
        launcher:cellCountX="4" 
        launcher:cellCountY="4" 
        launcher:pageSpacing="@dimen/workspace_page_spacing" 
        launcher:scrollIndicatorPaddingLeft="@dimen/workspace_divider_padding_left" 
        launcher:scrollIndicatorPaddingRight="@dimen/workspace_divider_padding_right"> 
 
        <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 layout="@layout/hotseat"//Hotseat,这块dock区域--包含了一个CellLayout,用来承载4个图标和中间启动所有程序的按钮
        android:id="@+id/hotseat" 
        android:layout_width="match_parent" 
        android:layout_height="@dimen/button_bar_height_plus_padding" 
        android:layout_gravity="bottom"  /> 
 
    <include //sb_bar,就是屏幕最顶端的Google搜索框。对桌面进行翻页的时候,这个搜索框会巍然不动滴固定在最顶端
        android:id="@+id/qsb_bar" 
        layout="@layout/qsb_bar"  /> 
 <!----------紧接着是3个初始化时被隐藏的界面。------------------>
    <include layout="@layout/apps_customize_pane" //点击dock中按钮显示了所有应用程序和所有插件的界面
        android:id="@+id/apps_customize_pane" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:visibility="invisible"  /> 
 <!--------下面两个是刚刷完机后,进入桌面时,显示的使用向导界面------------>
    <include layout="@layout/workspace_cling" 
        android:id="@+id/workspace_cling" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:visibility="gone"  /> 
 
    <include layout="@layout/folder_cling" 
        android:id="@+id/folder_cling" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:visibility="gone"  /> 
</com.android.launcher2.DragLayer> 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值