简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM