launcher修改--修改launcher的屏幕數
首先,在Launcher.java代碼中,第125行
[java] view plaincopy
- static final int SCREEN_COUNT = 5;
- static final int DEFAULT_SCREEN = 2;//第一頁是從0開始計數,這里是把第三個頁面作為默認首頁
第一個參數定義屏幕個數,第一個參數是默認的首頁。在這里,你可以做出自己的修改。但是,僅這點修改,遠遠不夠,我們看一下launcher.xml
[html] view plaincopy
- <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。在這里,你可能也注意到了
[html] view plaincopy
- launcher:defaultScreen="2">
在這里定義的defaultScreen。
同時,要修改workspace.java中180
[html] view plaincopy
- mDefaultScreen = a.getInt(R.styleable.Workspace_defaultScreen, 1);
和res/xml文件中default_workspace做出相應的修改。這樣就基本上可以了。