【发布时间】:2013-08-21 16:05:51
【问题描述】:
我有一个应用程序可以将壁纸应用到主屏幕,其中包含与屏幕尺寸相匹配的图像。 这是我设置壁纸的代码:
WallpaperManager wallpaperManager = WallpaperManager.getInstance(MainActivity.this);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
try {
BitmapFactory.decodeResource(getResources(), wallpapersPagerAdapter.getWallpaperId(position), options);
wallpaperManager.suggestDesiredDimensions(options.outWidth, options.outHeight);
wallpaperManager.setResource(wallpapersPagerAdapter.getWallpaperId(position));
} catch (IOException e) {
Log.e(Constants.LOG_TAG, e.getMessage());
Toast.makeText(MainActivity.this, R.string.err_can_not_set_wallpaper, Toast.LENGTH_SHORT).show();
return;
}
它在大多数设备上都能完美运行,但suggestDesiredDimensions() 对 Galaxy s4 和 Galaxy s3 完全没有影响(我想其他三星手机也会有同样的问题)。在此手机上,无论所需尺寸如何,图像都会被缩放。
但我发现Backgrounds HD 应用程序没有这个问题。所以我想知道如果我的壁纸的实际尺寸为 1080x1920,如何在不裁剪的情况下在 Galaxy s4(或 s3)上设置壁纸?
【问题讨论】:
标签: android wallpaper homescreen