首先,在Launcher.java代碼中,第125行
- static final int SCREEN_COUNT = 5;
- static final int DEFAULT_SCREEN = 2;//第一頁(yè)是從0開(kāi)始計(jì)數(shù),這里是把第三個(gè)頁(yè)面作為默認(rèn)首頁(yè)
第一個(gè)參數(shù)定義屏幕個(gè)數(shù),第一個(gè)參數(shù)是默認(rèn)的首頁(yè)。在這里,你可以做出自己的修改。但是,僅這點(diǎn)修改,遠(yuǎn)遠(yuǎn)不夠,我們看一下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>
我們可以看到 導(dǎo)入了五個(gè)workspace_screen,在這里,參照你上面修改的參數(shù),添加或者刪除workspace_screen。在這里,你可能也注意到了
- launcher:defaultScreen="2">
在這里定義的defaultScreen。
同時(shí),要修改workspace.java中180
- mDefaultScreen = a.getInt(R.styleable.Workspace_defaultScreen, 1);
和res/xml文件中default_workspace做出相應(yīng)的修改。這樣就基本上可以了。