开发者

Size of background images to support all medium and large android screens

I'm writing an app and I want one of my activities to have a background,

I've read the android docs about supporting multiple resolutions etc, but my designer is asking me what size the wallpapers should be and I do not want a lot of images for low,normal,high dpi in all the screen sizes.

What would be the most space efficient way to get a nice screen filling graphic background on all those screens?

开发者_运维技巧

Android is great and all, but I do not want to end up with a huge app since I need all sizes of images for everything.


One approach is to design for the densities and use the Icon Design guidelines for icons, and the dimensions specified in the "Range of Screens" area in the Supporting Multiple Screens guide for your background images.

For the background images be sure to take the status bar dimensions into consideration.

You can put your resources in the appropriate drawable-mdpi, drawable-hdpi, drawable-ldpi folders and they will be used appropriately.


What about having only one high resolution landscape background and using a "stretch" strategy for display?

    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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜