2020521y
Launcher3的Wallpaper显示是动态的,与Launcher预置桌面屏数有关,只能确保第一次开机时壁纸居中。如果用户修改桌面数目,就无法让壁纸仍然
居中。以默认只有1屏为例:
请修改Launcher3的Workspace.java的updateOffset方法,如下:
private void updateOffset(boolean force) {
if (mWaitingForUpdate || force) {
mWaitingForUpdate = false;
LauncherLog.d(TAG, "updateOffset: mWallpaperOffset = " + mWallpaperOffset.getCurrX());
if (computeScrollOffset() && mWindowToken != null) {
try {
if (getChildCount() <= 1) {
LauncherLog.d(TAG, "Default screen number is 1.");
mWallpaperManager.setWallpaperOffsets(mWindowToken,
0.5f, 0.5f);
}else{
LauncherLog.d(TAG, "Default screen number >= 1.");
mWallpaperManager.setWallpaperOffsets(mWindowToken,
mWallpaperOffset.getCurrX(), 0.5f);
}
setWallpaperOffsetSteps();
} catch (IllegalArgumentException e) {
Log.e(TAG, "Error updating wallpaper offset: " + e);
}
}
}
}
注意:不能将桌面默认屏设置为非0屏,否则Launcher可能会报出各种Exception。

分类:

技术点:

相关文章:

  • 2022-02-11
  • 2021-11-05
  • 2021-10-03
  • 2021-05-04
  • 2021-09-30
  • 2022-01-02
  • 2021-12-13
  • 2021-11-03
猜你喜欢
  • 2021-12-14
  • 2021-10-21
  • 2021-09-22
  • 2021-07-24
  • 2021-07-28
  • 2021-08-15
相关资源
相似解决方案