我正在制作一个壁纸应用程序,我有一个问题:当我尝试单击“设置背景”按钮时,它会设置背景但它被放大了,因此我丢失了一半的原始图像。这是我正在使用的代码:
try {
Display d = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int width = d.getWidth();
int height = d.getHeight();
WallpaperManager wallpaperManager = WallpaperManager.getInstance(view.getContext());
Bitmap bitmap = null;
bitmap = Bitmap.createScaledBitmap(bmpWallpaper, width, height, false);
wallpaperManager.setBitmap(bitmap);
Core.makeNotification(view.getContext(), "MyNotification", "Your wallpaper has been set, enjoy!");
Core.makeAlert(view.getContext(), "Wallpaper set", "Your wallpaper has been set, enjoy!");
} catch (IOException e) {
e.printStackTrace();
}