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;
}