1

我正在编写一个应用程序,我希望我的一项活动有背景,

我已经阅读了有关支持多种分辨率等的 android 文档,但是我的设计师问我壁纸应该是什么尺寸,我不希望在所有屏幕尺寸中都有很多低、正常、高 dpi 的图像。

在所有这些屏幕上获得漂亮的屏幕填充图形背景的最节省空间的方法是什么?

Android 非常棒,但我不想最终得到一个巨大的应用程序,因为我需要所有大小的图像。

4

2 回答 2

1

一种方法是设计密度并使用图标的图标设计指南,以及在支持多屏幕指南的“屏幕范围”区域中为背景图像指定的尺寸。

对于背景图像,请务必考虑状态栏尺寸。

您可以将您的资源放在适当的 drawable-mdpi、drawable-hdpi、drawable-ldpi 文件夹中,它们将被适当地使用。

于 2010-06-25T16:40:45.583 回答
0

如果只有一个高分辨率风景背景并使用“拉伸”策略进行显示呢?

    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);
}
于 2014-12-31T14:51:39.393 回答