我正在从应用程序中设置图像作为墙纸,它在诺基亚5上运行良好,并且正在设置图像并填充整个视图,但是当我尝试在huawei Honor 5x或nexus 4上运行相同的代码时图像被放大并离开主屏幕。
private Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) {
int width = bm.getWidth();
int height = bm.getHeight();
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
// create a matrix for the manipulation
Matrix matrix = new Matrix();
// resize the bit map
matrix.postScale(scaleWidth, scaleHeight);
// recreate the new Bitmap
Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, true);
return resizedBitmap;
}