展会信息港展会大全

修改launcher的屏幕参数
来源:互联网   发布日期:2016-01-06 19:23:48   浏览:2769次  

导读:首先,在Launcher.java代码中,第125行staticfinalintSCREEN_COUNT=5;staticfinalintDEFAULT_SCREEN=2;//第一页是从0开始计数,这里是把第三个页面作为默认首页第一个参数定义屏幕个数,第一个参数是默认的首页。......

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

赞助本站

人工智能实验室

相关热词: 屏幕参数 launcher

AiLab云推荐
推荐内容
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港