1

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.

Mervin
  • 1,103
  • 4
  • 18
  • 26

2 Answers2

1

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.

keno
  • 2,956
  • 26
  • 39
  • that would mean that I would need 5 differently sized wallpapers (not writing for small screen), I'm not displaying the status bar since it's a game. – Mervin Jun 25 '10 at 20:28
  • I'm assuming since it's a game, you are only doing landscape. You would only need 1 for mdpi which would be 480x320 ... 2 for hdpi, 800x480 and 854x480 ... so 3 in total – keno Jun 26 '10 at 04:07
0

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);
}
A. Masson
  • 2,287
  • 3
  • 30
  • 36