为什么在(少数)Android设备上设置1x1像素壁纸失败?
要在Android设备上设置黑色或纯色墙纸,可以使用像素设置为该颜色的小1x1像素图像。这适用于大多数Android设备(包括Nexus设备和其他运行Android股票的设备)。该系统知道如何用一个像素填充整个屏幕,为您提供全纯色墙纸 但是,有些Android设备在设置1x1像素图像壁纸后立即出现错误:为什么在(少数)Android设备上设置1x1像素壁纸失败?,android,android-bitmap,wallpaper,homescreen,android-wallpaper,Android,Android Bitmap,Wallpaper,Homescreen,Android Wallpaper,要在Android设备上设置黑色或纯色墙纸,可以使用像素设置为该颜色的小1x1像素图像。这适用于大多数Android设备(包括Nexus设备和其他运行Android股票的设备)。该系统知道如何用一个像素填充整个屏幕,为您提供全纯色墙纸 但是,有些Android设备在设置1x1像素图像壁纸后立即出现错误: 不幸的是,系统UI已停止 不幸的是,家已经停止了 尝试稍微大一点的图像大小(2x2、3x3、4x4)也会失败 我刚刚创建了一个开源Android应用程序来测试这个问题:。它的源代码是可用的
- 不幸的是,系统UI已停止李>
- 不幸的是,家已经停止了李>
public static Bitmap createColorSwatchBitmap(int width, int height, int color) {
final Bitmap colorBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
colorBitmap.eraseColor(color);
return colorBitmap;
}
及
到目前为止,我有一个屏幕截图报告,在Allview P8 Energy上,工作的最小壁纸尺寸是32x32。从我参与的另一个项目中,我了解到1x1壁纸在以下设备上也会出现故障:
- LG:G5,触针2
- 魅族:m1注,m2注,m3注,MX5,Pro 6
final WallpaperManager wpManager = WallpaperManager.getInstance(context);
final Bitmap colorBitmap = ColorUtils.createColorSwatchBitmap(width, height, color);
wpManager.setBitmap(colorBitmap);