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

     首先,在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做出相应的修改。这样就基本上可以了。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值