终于开始分配正式的任务给我了, 今天开始launcher的学习和研究,之前没有接触过launcher的人尅跟着我的学习来哦,都是从基础的说起,里面有很多的东西,大神们都是不屑于看的,新手倒是可以看看哦,让我们一起走进launcher的学习之旅,共同努力,共同进步,加油.。You are best!!!
一、 首先我们来看看launcher的布局方面的东西
Launcher.java中定义布局
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
…………
setContentView(R.layout.launcher);
…………
}
接着来看看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" 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 android:id="@+id/qsb_divider" layout="@layout/workspace_divider" …………/> <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 ………… > <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/workspace_divider" …………/> <include layout="@layout/apps_customize_pane" …………/> <include layout="@layout/hotseat" …………/> <include layout="@layout/workspace_cling" …………/> <include layout="@layout/folder_cling" …………/> </com.android.launcher2.DragLayer>
我们来看你一下布局文件,结合图片我们来一个一个来看看这些布局空间:
1、 最外面的Draglayer是一个FrameLayout的View控件,是最外面的一层,其他所有的控件都是在这一层上面
2、 android:id="@+id/qsb_divider",使用了workspace_divider布局,就是workspace和hotseat之间的那条线
3、 android:id="@+id/paged_view_indicator"
layout="@layout/scroll_indicator"
使用了scroll_indicator布局,就是只在workspace_divider上面指示是哪一个界面的那条蓝色的线
4、 workspace 包含了五个子界面,五个cell,每一个都是workspace_screen布局,就是那个上面可以防止shortcut和widget的布局
共有5个这样的界面哦 ~
5、 qsb_bar 使用了qsb_bar布局
就是界面上的那个搜索框
有两个,需要在使用的时候手动切换的 ~
6、 apps_customize_pane 主菜单
主菜单,列出了所有的安装在手机上的应用程序
7、 layout="@layout/hotseat"
android:id="@+id/hotseat"
就是手机屏幕最下面的那五个快捷键的位置
8、 后面还有两个cling,指示器,就是在第一次开机使用的时候,提示用户如何使用的向导,再则就不贴图了
后面,我们就来分别看看每一个布局文件的具体内容,看它是如何使用的,又有哪些方面的功能和操作 ~~~~