Launcher3的wallpaper显示是动态的,与Launcher预置桌面数目有关,让壁纸居中,仅仅能确保第一次开机时壁纸居中,后面用户改动桌面数目后,就无法达到了。怎样要在默认桌面数目配置时居中。能够參考以下方法。以default一屏为例:
Launcher3的workspace.java文件替换以下的函数
private void updateOffset(boolean force) {
if (mWaitingForUpdate || force) {
mWaitingForUpdate = false;
if (computeScrollOffset() && mWindowToken != null) {
try {
if (getChildCount() <= 1) {
mWallpaperManager.setWallpaperOffsets(mWindowToken,
/* mWallpaperOffset.getCurrX()*/0.5f, 0.5f);
}else{
mWallpaperManager.setWallpaperOffsets(mWindowToken,
mWallpaperOffset.getCurrX(), 0.5f);
}
setWallpaperOffsetSteps();
} catch (IllegalArgumentException e) {
}
}
}
}
Launcher3的workspace.java文件替换以下的函数
private void updateOffset(boolean force) {
if (mWaitingForUpdate || force) {
mWaitingForUpdate = false;
if (computeScrollOffset() && mWindowToken != null) {
try {
if (getChildCount() <= 1) {
mWallpaperManager.setWallpaperOffsets(mWindowToken,
/* mWallpaperOffset.getCurrX()*/0.5f, 0.5f);
}else{
mWallpaperManager.setWallpaperOffsets(mWindowToken,
mWallpaperOffset.getCurrX(), 0.5f);
}
setWallpaperOffsetSteps();
} catch (IllegalArgumentException e) {
}
}
}
}