背景图像的尺寸以支持所有中和大型Android屏幕
-
30-09-2019 - |
题
我正在写一个应用程序,我希望我的一项活动具有背景,
我已经阅读了有关支持多种分辨率等的Android文档,但是我的设计师问我壁纸应该是多少,我不希望在所有屏幕尺寸的低,正常,高的DPI上进行很多图像。
在所有这些屏幕上获得一个漂亮的屏幕填充图形背景的最有效的方法是什么?
Android很棒,而且一切都很棒,但是我不想最终获得一个巨大的应用程序,因为我需要所有内容的所有尺寸图像。
其他提示
只有一个高分辨率的景观背景并使用“拉伸”策略进行显示又如何呢?
mBackgroundGraphic = BitmapFactory.decodeResource(getResources(), R.drawable.background);
mBackgroundGraphic = getResizedBitmap(mBackgroundGraphic);
public Bitmap getResizedBitmap(Bitmap bm) {
int width = bm.getWidth();
int height = bm.getHeight();
int displayWidth = mDisplay.getWidth();
int displayHeight = mDisplay.getHeight();
float scaleWidth = ((float) displayWidth) / width;
float scaleHeight = ((float) displayHeight) / height;
// Create a matrix for the manipulation
Matrix matrix = new Matrix();
// Resize the bit map
matrix.postScale(scaleWidth, scaleHeight);
// Return the new stretched Bitmap
return Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
}
不隶属于 StackOverflow