在主屏幕上设置可滚动的墙纸
set scrollable wallpaper across homescreen
我想在主屏幕上设置可滚动墙纸,但我的墙纸会自动中心裁剪。
我使用的图像比例为“3:2/16:9”,所以我希望它们均匀分布在主屏幕的多个页面上。
我目前正在使用:
wallpaperManager.suggestDesiredDimensions(width, height);
wallPaperBitmap = BitmapFactory.
decodeStream(url);
wallpaperManager.setBitmap(wallPaperBitmap);
`
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21"/>
得到androidhive.com
的帮助
//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));
我想在主屏幕上设置可滚动墙纸,但我的墙纸会自动中心裁剪。 我使用的图像比例为“3:2/16:9”,所以我希望它们均匀分布在主屏幕的多个页面上。
我目前正在使用:
wallpaperManager.suggestDesiredDimensions(width, height);
wallPaperBitmap = BitmapFactory.
decodeStream(url);
wallpaperManager.setBitmap(wallPaperBitmap);
`
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21"/>
得到androidhive.com
的帮助//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));