在某些设备上,WallpaperManager将墙纸缩放得太小。我使用了以下代码。
Bitmap srcBitmap = .....
WallpaperManager wm = WallpaperManager
.getInstance(getApplicationContext());
int height = wm.getDesiredMinimumHeight();
int width = wm.getDesiredMinimumWidth();
wm.setBitmap(Bitmap.createScaledBitmap(srcBitmap, width , height , true);在android 4.0.4的galaxy note上,墙纸占满了整个屏幕。但在2.3版本的galaxy s2上,墙纸只填满了屏幕中央的一个小矩形。
大家好,
mp5
发布于 2013-02-01 16:39:58
问题是wm.getDesiredMinimumHeight();和wm.getDesiredMinimumWidth();在某些设备上返回-1。因此,Bitmap.createScaledBitmap(srcBitmap, width , height , true);失败,并使用srcBitmap的原始大小。
发布于 2013-07-02 04:44:15
这将适合屏幕与您的位图宽度和高度
WallpaperManager wallmanage = (WallpaperManager) getSystemService(WALLPAPER_SERVICE);
wallmanager.setBitmap(bitmap);
wallmanager.suggestDesiredDimensions(w, h);
where w = bitmap.getWidth();
and h = bitmap.getHeight();https://stackoverflow.com/questions/14366609
复制相似问题