life02

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  197 随笔 :: 3 文章 :: 37 评论 :: 0 Trackbacks
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, -10new 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);
    }
posted on 2012-07-26 16:29 life02 阅读(503) 评论(0)  编辑 收藏 引用 所属分类: Android开发

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理