launcher修改--修改launcher的屏幕数

迷途d书童 发布于 2012/03/30 14:07
阅读 3K+
收藏 1

        首先,在Launcher.java代码中,第125行

static final int SCREEN_COUNT = 5;
static final int DEFAULT_SCREEN = 2;//第一页是从0开始计数,这里是把第三个页面作为默认首页

第一个参数定义屏幕个数,第一个参数是默认的首页。在这里,你可以做出自己的修改。但是,仅这点修改,远远不够,我们看一下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">

    <include layout="@layout/all_apps" />

    <!-- The workspace contains 3 screens of cells -->
    <com.android.launcher2.Workspace
        android:id="@+id/workspace"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="horizontal"
        android:fadeScrollbars="true"
        launcher:defaultScreen="2">

        <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>

我们可以看到 导入了五个workspace_screen,在这里,参照你上面修改的参数,添加或者删除workspace_screen。在这里,你可能也注意到了

 launcher:defaultScreen="2">

在这里定义的defaultScreen。

同时,要修改workspace.java中180

mDefaultScreen = a.getInt(R.styleable.Workspace_defaultScreen, 1);

和res/xml文件中default_workspace做出相应的修改。这样就基本上可以了。


原文链接: http://blog.csdn.net/aomandeshangxiao/article/details/6910533
加载中
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部