java墙纸未缩放到设备的显示
我想通过单击按钮将图像设置为设备的壁纸
我设置了点击监听器(setWall),但图像没有缩放到设备的显示
imageBrought = getIntent().getExtras().getString("appMomentImage");
Glide.with(getApplicationContext()).load(imageBrought).dontAnimate().into(imagePreview);
setWall.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Glide.with(getApplicationContext()).load(imageBrought).asBitmap().into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
try {
WallpaperManager.getInstance(getApplicationContext()).setBitmap(resource);
} catch (IOException e) {
e.printStackTrace();
}
Toast.makeText(getApplicationContext(), "Your Wallpaper Has Been Set!", Toast.LENGTH_LONG).show();
}
});
}
});
# 1 楼答案
你可以用这个来获取你的设备指标,然后传递给你的图像大小