AndroidL中修改launcher3主菜单布局

Android4.4之后的Launcher3,主菜单布局的行数和列数,都是在DynamicGrid.java中动态计算的,xml中无法配置。

如果想修改主菜单的布局,调整行数和列数,需要修改DynamicGrid.java中对应的值.

DynamicGrid.java中allAppsNumRows和allAppsNumCols的值.

allAppsNumRows = (availableHeightPx - pageIndicatorOffset - 4 * edgeMarginPx) /(iconSizePx + iconTextSizePx + 2 * edgeMarginPx);


allAppsNumCols = (availableWidthPx - padding.left - padding.right - 2 * edgeMarginPx) /(iconSizePx + 2 * edgeMarginPx);

源码中:

DeviceProfile(String n, float w, float h, float r, float c,
                  float is, float its, float hs, float his) {
        // Ensure that we have an odd number of hotseat items (since we need to place all apps)
        if (!AppsCustomizePagedView.DISABLE_ALL_APPS && hs % 2 == 0) {
            throw new RuntimeException("All Device Profiles must have an odd number of hotseat spaces");
        }

        name = n;
        minWidthDps = w;
        minHeightDps = h;
        numRows = r;
        numColumns = c;
        iconSize = is;
        iconTextSize = its;
        numHotseatIcons = hs;
        hotseatIconSize = his;
    }
从网络处获得。对应的数据均为默认值http://www.bubuko.com/infodetail-541421.html

 DeviceProfile(String n, float w, float h, float r, float c,
                  float is, float its, float hs, float his) {
        // Ensure that we have an odd number of hotseat items (since we need to place all apps)
        if (!LauncherAppState.isDisableAllApps() && hs % 2 == 0) {
            throw new RuntimeException("All Device Profiles must have an odd number of hotseat spaces");
        }
        //Log.v("zxxl",">>n="+n+">>>>w="+w+">>>>>h="+h+">>>>r="+r+">>>>c="+c+">>>>is="+is+">>>its="+its+">>>hs="+hs+">>>his="+his);
        name = n;
        minWidthDps = 1200;
        minHeightDps = 1920;
        numRows = 5;
        numColumns = 6;
        iconSize = 68;
        iconTextSize = 14.4f;
        numHotseatIcons = 7;
        hotseatIconSize = 72;
    }


如何更改android 4.4.4上的launcher3默认布局

我们在android 4.4之前,launcher里设置默认桌面布局,一般都是更改的default_workspace.xml这个文件,
但是在android4.4.4后,launcher3上,却好像是用了数据库来代替了布局文件 ,
现在无论如何修改哪个目录下的default_workspace.xml,都不会起任何作用,求大神们指点下,
如果要改用default_workspace.xml来配置桌面布局,该如何做?
android4.4.4也是通过default_workspace.xml来修改的.文件
LauncherProvider.java里的loadDefaultFavoritesIfNecessary() 方法
这中的if (sp.getBoolean(EMPTY_DATABASE_CREATED, false)) { 注释掉即可.


 
  

你可能感兴趣的:(AndroidL,Launcher3)