The wallpaper display of KK Launcher3 is dynamic, which is related to the preset number of Launcher desktops. to center the wallpaper, you can only ensure that the wallpaper is centered during the first boot. After you modify the number of desktops, the wallpaper cannot be reached. To center the default number of desktops, refer to the following method. Take the default screen as an example: Replace the following function private void updateOffset (boolean force) in the workspace. java file of Launcher3 ){
If (mWaitingForUpdate | force ){
MWaitingForUpdate = false;
LauncherLog. d (TAG, updateOffset: mWallpaperOffset = + mWallpaperOffset. getCurrX ());
If (computescroloffset () & mWindowToken! = Null ){
Try {
If (getChildCount () <= 1 ){
LauncherLog. d (TAG, fig offset 111 );
MWallpaperManager. setWallpaperOffsets (mWindowToken,
/* MWallpaperOffset. getCurrX () */0.5f, 0.5f );
} Else {
LauncherLog. d (TAG, fig offset 222 );
MWallpaperManager. setWallpaperOffsets (mWindowToken,
MWallpaperOffset. getCurrX (), 0.5f );
}
SetWallpaperOffsetSteps ();
} Catch (IllegalArgumentException e ){
Log. e (TAG, Error updating wallpaper offset: + e );
}
}
}
}