http://blog.csdn.net/the01hierarch/article/details/7631081
1.左滑切換到顯示所有apps
PageView.java->onTouchEvent->case MotionEvent.ACTION_UP->if (mTouchState == TOUCH_STATE_SCROLLING)->else { snapToDestination();->后添加
if(((isSignificantMove && deltaX > 0 && !isFling) ||
(isFling && velocityX > 0)) && mCurrentPage == 0)
{
snapToLeftDestination();
}
并在Workspace.java中重寫函數
protected void snapToLeftDestination() {
mLauncher.showAllApps(true);
}
2.靜態添加屏幕和屏幕上的快捷鍵
http://blog.csdn.net/the01hierarch/article/details/7641521
android1.6的版本有3個屏 需要把它改為5個屏 需要修改的地方 如下
1、Launcher.java
Java代碼 收藏代碼
static final int SCREEN_COUNT = 5;
static final int DEFAULT_SCREN = 2;
2、launcher.xml
Java代碼 收藏代碼
<com.lp.launcher.Workspace
android:id="@+id/workspace"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
launcher:defaultScreen="2">//從0開始
<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.lp.launcher.Workspace>
defaultScreen 修改為2 然后 加兩個<include />
然后 修改默認顯示的屏
3、Workspace.java
修改構造方法里面的
Java代碼 收藏代碼
mDefaultScreen = a.getInt(R.styleable.Workspace_defaultScreen, 2);//從0開始
這時 基本上已經可以顯示5個屏幕了 默認的屏也是第三個屏了 但是進去后 默認顯示的屏什么也沒有 我們需要把組建都挪到默認屏上去
4、default_workspace.xml
修改所有的 launcher:screen 為 2
Java代碼 收藏代碼
launcher:screen="2"
3.桌面最下方顯示3個指定快捷方式
方法一:在launcher.xml中刪除
<include
android:id="@+id/hotseat"
android:layout_width="match_parent"
android:layout_height="@dimen/button_bar_height_plus_padding"
android:layout_gravity="bottom"
layout="@layout/hotseat"/>
并添加相應的按鈕
方法二:修改default_workspace.xml
方法三:如果是定死熱鍵,不可改變的話不推薦
重寫LauncherModel->loadWorkspace中獲得的數據方法,其中sWorkspaceItems.add(info);就是添加快捷方式(包括桌面widget和下面的熱鍵)
在Hotseat->resetLayout->刪除mContent.addViewToCellLayout(allAppsButton, -1, 0, new CellLayout.LayoutParams(x,y,1,1), true);
4.動態添加屏幕
在launcher.java中添加兩個按鍵事件---------之后可以將這兩個按鈕作為appwidget加到默認的桌面上,和launcher交互用動態(內部注冊)廣播
public void addScreen(View view)
{
LayoutInflater mInflater = LayoutInflater.from(this);
CellLayout mCelllayout =(CellLayout)mInflater.inflate(R.layout.workspace_screen,null);
mWorkspace.addView(mCelllayout);
mWorkspace.requestLayout();
}
public void removeScreen(View view)
{
int currentPage = mWorkspace.getCurrentPage();
int countPage = mWorkspace.getChildCount();
if(countPage > 1)
{
if(currentPage == (countPage - 1))
{
currentPage--;
}
mWorkspace.removeViewAt(countPage - 1);
}
mWorkspace.requestLayout();
mWorkspace.snapToPage(currentPage);
}
1.左滑切換到顯示所有apps
PageView.java->onTouchEvent->case MotionEvent.ACTION_UP->if (mTouchState == TOUCH_STATE_SCROLLING)->else { snapToDestination();->后添加
if(((isSignificantMove && deltaX > 0 && !isFling) ||
(isFling && velocityX > 0)) && mCurrentPage == 0)
{
snapToLeftDestination();
}
并在Workspace.java中重寫函數
protected void snapToLeftDestination() {
mLauncher.showAllApps(true);
}
2.靜態添加屏幕和屏幕上的快捷鍵
http://blog.csdn.net/the01hierarch/article/details/7641521
android1.6的版本有3個屏 需要把它改為5個屏 需要修改的地方 如下
1、Launcher.java
Java代碼 收藏代碼
static final int SCREEN_COUNT = 5;
static final int DEFAULT_SCREN = 2;
2、launcher.xml
Java代碼 收藏代碼
<com.lp.launcher.Workspace
android:id="@+id/workspace"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
launcher:defaultScreen="2">//從0開始
<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.lp.launcher.Workspace>
defaultScreen 修改為2 然后 加兩個<include />
然后 修改默認顯示的屏
3、Workspace.java
修改構造方法里面的
Java代碼 收藏代碼
mDefaultScreen = a.getInt(R.styleable.Workspace_defaultScreen, 2);//從0開始
這時 基本上已經可以顯示5個屏幕了 默認的屏也是第三個屏了 但是進去后 默認顯示的屏什么也沒有 我們需要把組建都挪到默認屏上去
4、default_workspace.xml
修改所有的 launcher:screen 為 2
Java代碼 收藏代碼
launcher:screen="2"
3.桌面最下方顯示3個指定快捷方式
方法一:在launcher.xml中刪除
<include
android:id="@+id/hotseat"
android:layout_width="match_parent"
android:layout_height="@dimen/button_bar_height_plus_padding"
android:layout_gravity="bottom"
layout="@layout/hotseat"/>
并添加相應的按鈕
方法二:修改default_workspace.xml
方法三:如果是定死熱鍵,不可改變的話不推薦
重寫LauncherModel->loadWorkspace中獲得的數據方法,其中sWorkspaceItems.add(info);就是添加快捷方式(包括桌面widget和下面的熱鍵)
在Hotseat->resetLayout->刪除mContent.addViewToCellLayout(allAppsButton, -1, 0, new CellLayout.LayoutParams(x,y,1,1), true);
4.動態添加屏幕
在launcher.java中添加兩個按鍵事件---------之后可以將這兩個按鈕作為appwidget加到默認的桌面上,和launcher交互用動態(內部注冊)廣播
public void addScreen(View view)
{
LayoutInflater mInflater = LayoutInflater.from(this);
CellLayout mCelllayout =(CellLayout)mInflater.inflate(R.layout.workspace_screen,null);
mWorkspace.addView(mCelllayout);
mWorkspace.requestLayout();
}
public void removeScreen(View view)
{
int currentPage = mWorkspace.getCurrentPage();
int countPage = mWorkspace.getChildCount();
if(countPage > 1)
{
if(currentPage == (countPage - 1))
{
currentPage--;
}
mWorkspace.removeViewAt(countPage - 1);
}
mWorkspace.requestLayout();
mWorkspace.snapToPage(currentPage);
}