I am developing my first Android OpenGL game. It's a 2D game and I would like the background to always fill the screen. I've managed to achieve this by stretching the texture to fit the size of the screen based on the aspect ratio, but the texture becomes quite pixelated when stretched.

What is the correct way to achieve this?


2 Answers 2


You could choose from those options:

  • Make the texture big enough to avoid stretching - scale down and crop only
  • Include differently size versions of the background and select depending on screen resolution
  • Make up your background from several smaller textures which you can place next to each other to fill the screen

If the background is static you could probably come up with a background size which works well across most devices because the general form factor is similar - unless you also target pads in which case you probably need two versions anyway. The third option mentioned is suitable if the background can be constructed from repeatable tiles, like a brick wall.

  • 1
    \$\begingroup\$ +1 Superb answer. The only other option I can think of is to use a tiling background. If you have a border, make the corners fixed assets and tile the edges. \$\endgroup\$ Commented Oct 24, 2011 at 10:40
  • \$\begingroup\$ Is there no pixalization from scaling down? \$\endgroup\$
    – Jason
    Commented Oct 24, 2011 at 17:24
  • \$\begingroup\$ Scaling down should result in a smooth image as long as you use filtering. Supply true as the filter parameter in CreateScaledBitmap. It might look a little bit more blurry depending on how much you have to scale down. You should also try to keep the aspect ratio of the image, i.e. scale the same amount on the width and height dimension of the image. \$\endgroup\$
    – jmp97
    Commented Oct 25, 2011 at 6:41

You have multiple problems to solve here. Your background has the same type of constrain as most textures and 2d assets. Your textures (and other assets) have to adapt to hardware with:

  • different resolutions
  • different aspect ratios
  • different pixel densities
  • and different performances

In this case you will have to make sure that your game looks good on the best hardware and is not a pile of crap on the rest you have to make compromises. First, you will have to ensure that you have assets for the best hardware and the worst (think pixel densities).

So make your assets for high resolution screens. Make sure you support the highest resolution available.

Also make sure your background has room for different aspect ratios. Therefore make it so you have room on the sides to expand on larger or higher screens.

Ensure that you use the information about pixel density screen size and other indicators to avoid displaying the wrong assets. The resolution is not necessarily the best way to decide which asset to use. For example text must be readable on high density screens and it should be smaller on low density large screens (tablets) so if you have some details to show in your background you might want to dissociate the details the user must see from the background and ensure users can see them on all devices (density/size/form factor).

And finally to accommodate most of the form-factors and use the lowest footprint you might want to divide the largest resources into tiles or crop them at runtime. To reduce processing time at initialization you might also want to add assets for lower density and lower quality screens.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .