文档介绍:【专家专栏】Android Launcher 源码分析系列(一)............................................................1
【专家专栏】Android Launcher 源码分析系列(二)......................................................... 13
【专家专栏】Android Launcher 源码分析系列(三)......................................................... 20
【专家专栏】Android Launcher 源码分析系列(一)
2012-01-11 16:02 傻蛋 我要评论(2) 字号:T | T
著名手机厂商 Android 开发工程师、最牛网站长傻蛋曾为51CTO 撰稿《Android
加速及绘制技巧》受到读者的广泛欢迎。傻蛋同学将在新的一年里在 51CTO 开设专家专栏,本
文为傻蛋正在研究的一个方向,与网友共同探讨 Android ——Launcher。
AD:
从今天起傻蛋打算做一个系列文章,对最新的 Android 系统中的 Launcher,也就是
Android ,进行一个深入浅出的分析,从而引领 Android 系统的编程爱好者
对 Launcher 的设计思想,实现方式来做一个研究,从而能够通过这个实例最掌握到目前世界
领先的设计方法,同时在程序中加入我们的一些新的实现。众所周知,对一些优秀源代码的分
析,是提高编程水平的一条便捷的方式,希望本系列文章能够给大家带来一定的启发,同时欢
迎大家和作者一起讨论,作者的微博是:/zuiniuwang/
先从整体上对 Launcher 布局作一个分析, 让我们通过查看 和使用
hierarchyviewer 布局查看工具两者结合的方法来对 Launcher 的整体结构有个了解。通过
hierarchyviewer 来对整个桌面做个截图,如下:
放大后如下所示: 可以看到整个桌面包含的元素,最上面是 Google 的搜索框,下面是一
个始终插件,然后是图标,再有就是一个分隔线,最后是 dock。请注意,桌面程序其实并不包
含桌面壁纸,桌面壁纸其实是由 WallpaperManagerService 来提供,整个桌面其实是叠加在整
个桌面壁纸上的另外一个层。
点击查看大图
整个 布局文件如下:
1 <
2 xmlns:android ="http://schemas./apk/res/android"
3
xmlns:launcher ="http://schemas./apk/."
4
5 android:id ="@+id/drag_layer"
6 android:layout_width ="match_parent"
7 android:layout_height ="match_parent" >
8
9 <!-- Keep these behind the workspace so that they are not visible when
10 we go into AllApps -->
11 <include
12 android:id ="@+id/dock_divider"
13 layout="***@layout/workspace_divider"
14 android:layout_width ="match_parent"
15 android:layout_height ="wrap_content"
16 android:layout_marginBottom ="***@dimen/button_bar_height"
17 android:layout_gravity ="bottom" />
18 <include
19 android:id ="@+id/paged_view_indicator"
20 layout="***@layout/scroll_indicator"
21 android:layout_width ="wrap_content"
22 android:layout_height ="wrap_content"
23 android:layout_gravity ="bottom