Lanucherr 默认显示第几屏

Launcher.java

static final int SCREEN_COUNT = 5;
static final int DEFAULT_SCREEN = 2;//第一页是从0开始计数,这里是把第三个页面作为默认首页

launcher.xml

  <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"

workspace.java

mDefaultScreen = a.getInt(R.styleable.Workspace_defaultScreen, 1); 

workspace.xml

<com.android.launcher2.Workspace
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
    android:paddingTop="@dimen/workspace_content_large_only_top_margin"
    launcher:defaultScreen="2"                         修改默认HOME屏
    launcher:pageSpacing="@dimen/workspace_page_spacing">

workspace的布局如下:
 
(0,0)
(1,0)
(2,0)
(3,0)
(4,0)
(0,1)
(1,1)
(2,1)
(3,1)
(4,1)
(0,2)
(1,2)
(2,2)
(3,2)
(4,2)
作者:robert
出处:http://www.cnblogs.com/robertsun/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
如果文中有错误,欢迎指出。以免更多的人被误导。
欢迎留言交流。
原文地址:https://www.cnblogs.com/robertsun/p/4070031.html