墙纸不正确地放在设备屏幕上,它可以变焦或裁剪
我使用链接图像创建了带有滑行的壁纸应用程序。我有三个按钮可以将图像设置为墙纸,锁定屏幕和home_screen在设备屏幕上。但是,当我将此图像设置为墙纸时,它要么缩放或裁剪。我希望图像适合每个Android屏幕尺寸。
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.button2:
Bitmap bitmap1 = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
WallpaperManager manager1 = WallpaperManager.getInstance(getApplicationContext());
try {
manager1.setBitmap(bitmap1, null, false, WallpaperManager.FLAG_SYSTEM);
Toast.makeText(getApplicationContext(), "Set HomeScreen Successfully ", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
Toast.makeText(this, "Wallpaper not load yet!", Toast.LENGTH_SHORT).show();
}
break;
case R.id.button3:
Bitmap bitmap2 = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
WallpaperManager manager2 = WallpaperManager.getInstance(getApplicationContext());
try {
manager2.setBitmap(bitmap2, null, false, WallpaperManager.FLAG_LOCK);
Toast.makeText(getApplicationContext(), "Set LockScreen Successfully ", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
Toast.makeText(this, "Wallpaper not load yet!", Toast.LENGTH_SHORT).show();
}
break;
case R.id.button4:
Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
WallpaperManager manager = WallpaperManager.getInstance(getApplicationContext());
try {
manager.setBitmap(bitmap);
Toast.makeText(getApplicationContext(), "Set Wallpaper Successfully ", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
Toast.makeText(this, "Wallpaper not load yet!", Toast.LENGTH_SHORT).show();
}
}
}
}
I created wallpaper app with glide using link images. I have three buttons to set image as wallpaper, lock-Screen and Home_Screen on device screen. But when I set this image as wallpaper its either zoom or cropped. I want image should fit on every android screen size.
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.button2:
Bitmap bitmap1 = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
WallpaperManager manager1 = WallpaperManager.getInstance(getApplicationContext());
try {
manager1.setBitmap(bitmap1, null, false, WallpaperManager.FLAG_SYSTEM);
Toast.makeText(getApplicationContext(), "Set HomeScreen Successfully ", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
Toast.makeText(this, "Wallpaper not load yet!", Toast.LENGTH_SHORT).show();
}
break;
case R.id.button3:
Bitmap bitmap2 = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
WallpaperManager manager2 = WallpaperManager.getInstance(getApplicationContext());
try {
manager2.setBitmap(bitmap2, null, false, WallpaperManager.FLAG_LOCK);
Toast.makeText(getApplicationContext(), "Set LockScreen Successfully ", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
Toast.makeText(this, "Wallpaper not load yet!", Toast.LENGTH_SHORT).show();
}
break;
case R.id.button4:
Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
WallpaperManager manager = WallpaperManager.getInstance(getApplicationContext());
try {
manager.setBitmap(bitmap);
Toast.makeText(getApplicationContext(), "Set Wallpaper Successfully ", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
Toast.makeText(this, "Wallpaper not load yet!", Toast.LENGTH_SHORT).show();
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论