首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在主屏幕上设置可滚动墙纸

在主屏幕上设置可滚动墙纸
EN

Stack Overflow用户
提问于 2015-02-01 23:59:04
回答 1查看 698关注 0票数 1

我想在主屏幕上设置可滚动壁纸,但是我的壁纸自动获得中心裁剪。我使用的图片是"3:2/ 16:9“,所以我希望它们在多页上得到一致传播。

我目前正在使用:

代码语言:javascript
复制
wallpaperManager.suggestDesiredDimensions(width, height);
wallPaperBitmap = BitmapFactory.
                        decodeStream(url);

wallpaperManager.setBitmap(wallPaperBitmap);

`

代码语言:javascript
复制
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21"/>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-02-03 19:54:31

得到了androidhive.com的帮助

代码语言:javascript
复制
//get screen height
Display display = getWindowManager().getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        screenHeight = size.y;


 wallPaperBitmap= ... //your bitmap resource

//adjust the aspect ratio of the Image
//this is the main part
int width = wallPaperBitmap.getWidth();
            width = (width * screenHeight) / wallPaperBitmap.getHeight();
//set the wallpaper
//this may not be the most efficent way but it works
wallpaperManager.setBitmap(Bitmap.createScaledBitmap(wallPaperBitmap, width, height, true));
票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28269400

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档