1
我想设置一个位图作为androids壁纸,我已经找到了那部分。然而,图像总是太大,偏离中心并被裁剪。我试图调整位图的显示大小,但我仍然得到相同的结果,这里是我的一些代码。制作位图适合屏幕壁纸
Display display = getWindowManager().getDefaultDisplay();
final int maxWidth = display.getWidth();
final int maxHeight = display.getHeight();
Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL(img_url).getContent());
int imageHeight = bitmap.getHeight();
if (imageHeight > maxHeight)
imageHeight = maxHeight;
int imageWidth = (imageHeight*bitmap.getWidth())/bitmap.getHeight();
if (imageWidth > maxWidth) {
imageWidth = maxWidth;
imageHeight = (imageWidth*bitmap.getHeight())/bitmap.getWidth();
}
Bitmap resizedBitmap = Bitmap.createScaledBitmap(bitmap, imageWidth, imageHeight, true);
myWallpaperManager.setBitmap(resizedBitmap);
谁能帮我把壁纸图片的大小和正确集中的壁纸?
谢谢!
更接近。宽度是关闭的,但是,我读过的地方是它延伸图像显示在3个屏幕或什么? – Dan