Android的设置壁纸出了错 [英] Android setting wallpaper gone wrong

查看:339
本文介绍了Android的设置壁纸出了错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我制定壁纸更换很久以前的事,得到它释放。过了一会儿,我开始接受评论的壁纸没有正确调整。另外我想在不同尺寸的动车组,他们是对的。我正确地缩放位图等,但不知何故机器人倾向于重新调整墙纸更大!有没有办法避免这种情况?
我的code:

So I was developing wallpaper changer long time ago and got it released. After a while I started receiving comment the wallpaper not resizing correctly. Also I tried on different sizes of emus and they were right. I scale the bitmap correctly etc. but somehow android tends to rescale the wallpaper even bigger! Is there way to avoid that? My code:

Display display = parent.getWindowManager().getDefaultDisplay(); 
                    int width = display.getWidth();
                    int height = display.getHeight();
                    Bitmap scaled = Bitmap.createScaledBitmap(wallpaper, width, height, true);
                WallpaperManager wm = WallpaperManager.getInstance(getContext());
                wm.setBitmap(scaled);

我一直在尝试其他方法太多,但似乎没有任何帮助,即使我事后检查,如果重缩放后的壁纸是正确的大小等:(
任何想法?

I've been trying other ways too but nothing seems help, even if I afterwards check if the rescaled wallpaper is right size etc. :( Any ideas?

推荐答案

我要创建覆盖图像。


  1. 创建尺寸的空白图像WallpaperManager.getDesiredMinimumWidth() X WallpaperManager.getDesiredMinimumHeight()

调整您的位图筛选与显示显示= getWindowManager()getDefaultDisplay()的大小; BMP = Bitmap.createScaledBitmap( BMP,display.getWidth(),display.getHeight(),FALSE);

Resize your bitmap to screen size with, Display display = getWindowManager().getDefaultDisplay(); bmp = Bitmap.createScaledBitmap(bmp, display.getWidth(), display.getHeight(), false);

叠加的空白图像的中心,你的壁纸。并设置叠加壁纸。

Overlay your wallpaper on center of blank image. And set Overlay as wallpaper.

这篇关于Android的设置壁纸出了错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆