Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using this code to set a 800x420 image to be full screen:

public void show() {
    float w =;
    float h =;
    camera = new OrthographicCamera(1, h / w);
    batch = new SpriteBatch();
    texture = new Texture(Gdx.files.internal("images/splashatlas/splashatlas1.png"));
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    TextureRegion region =
    new TextureRegion(texture, 0, 0, 800, 420);
    sprite = new Sprite(region);
            0.9f * sprite.getHeight() / sprite.getWidth() );
            sprite.setOrigin(sprite.getWidth() / 2,
            sprite.getHeight() / 2);
            sprite.setPosition(-sprite.getWidth() / 2,
            -sprite.getHeight() / 2);

public void render(float delta) { 1f, 1f, 1f, 1f ); GL20.GL_COLOR_BUFFER_BIT );

But on real device it looks like this:

On a real device

I tried to setSize with different parameters:

            1.0f  );

Now it's fullscreen, but it's really stretched:

fullscreen, but stretched

What is the way to set a background to be full screen? I want it to look like this:

what I want

share|improve this question
change new TextureRegion(texture, 0, 0, 800, 420); to new TextureRegion(texture, 0, 0, w, h); – Thebluefish Mar 1 '14 at 13:03
this gives me a white screen. – Omar Mar 1 '14 at 13:06
this zoom the picture too much ... its looks blue now – Omar Mar 1 '14 at 13:13
i updated the question .. – Omar Mar 1 '14 at 13:14
ah ok, I had a chance to look at the documentation. try sprite.setSize(1.0f, 1.0f); – Thebluefish Mar 1 '14 at 13:18
up vote 3 down vote accepted

the problem was in my images size , i set the viewport to be 800x480 but the images size was 800x420 , i just changed the images size to 800x480 and in setSize() i changed it like the following :

            1f * sprite.getHeight() / sprite.getWidth() );

and its work perfectly now.

share|improve this answer
Consider using and as that will set the sprite to the size of the device's screen, regardless of the PPI. – user959631 Mar 4 '14 at 17:58
this will stretch the screen too much . – Omar Mar 6 '14 at 20:51
but anyway the method i used above should scale the splash screen according to the device width and height and regardless of the ppi – Omar Mar 6 '14 at 20:53

In your render() method, you could set, 0, 0, 0); which will set the background of your game to Black

Then you don't need to resize the sprite and the texture won't distort.

Hope this helped.

share|improve this answer
but this method will not give a good results if i decided to change my splash screen to colored sprite because it will be obvious that the splash in not full screen . but anyway thank you I've already solved my problem. – Omar Mar 4 '14 at 12:49
Oh, sorry, I wasn't aware that you would want to change the splash screen's color. – user959631 Mar 4 '14 at 17:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.