Android – Real background image size in android (with status bar)

androidbackgroundstatusbar

I'd like to use a high detail image as backrgound in my app, and I've got a problem with my designer because of this 😀

By now, we've got three image sizes (one per density) according to the most common devices' screen size, as we know:

  • low: 240 x 320 (e. HTC Tattoo)
  • mid:320 x 480 (e. HTC Magic)
  • high: 480 x 800 (e. Nexus One)

The problem is that, when I set an image as background, it gets resized, and I can see several horizontal "ghost" lines on it.

So we decided to resize the images with "height-minus-statusbar's height" (only in high-density one, just as test), having finally a 480 + 752 px image (according to http://developer.android.com/guide/practices/ui_guidelines/icon_design.html , the status bar's height is 48px)

But it still shows those "ghost" lines, so we think it's being resized again…

Could someone help me? I just want a normal background, with no resizing, but I don't know the real dimensions…

Thank you 😀

Best Answer

You are setting yourself up to be in a continual state of pain. You simply can not design against exact resolutions; there is too much variation in devices for that, and by doing so you are going to be slapped in the face continually as you encounter new devices. Android has a lot of facilities for dealing with this screen variety, such as 9-patches, its density management, layout managers, etc. If you take advantage of those, you will be happy; if you don't, you will be swearing all the time.

But if you want to swear, I can't stop you. Just please don't take to the net complaining about Android fragmentation. :)

As far as your image being scaled due to the status bar -- yes the status bar takes a chunk out of the screen. How much is not defined, so it could well vary slightly between devices. The window background, as set by Activity.getWindow().setBackgroundDrawable(), will extend behind the status bar (and IME or other variable system decoration), so at least using that will reduce the variation. That said, the actual display space could be carved out for other reasons from the physical screen size; it intentionally isn't defined exactly what part of the screen an app gets to play in.