문제

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);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top