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之前,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)) { 注釋掉即可.