[LibGDX] How to strech my game on android device?

I’m testing my game which is 480(width)x800(height) on a real android device but the game is a tiny fraction of the phones size and is at the bottom left corner of it. How do I stretch my game to fit the phones screen?

Change your matrix to use Gdx.graphics.getWidth() instead of 800

Look into using a viewport which stretches your specified ‘virtual screen’ size to fit the actual devices screen. There are several different types of viewport which scale the graphics to the screen in various ways, such as: FitViewport(480, 800). there is info on this on the libgdx documentation site.

This had nothing to do with viewport though, however do look into this for maintaining aspect ratio and desires resolution over all devices.

What you need to do is set the sprite batch projection to the cameras using:

spritebatch.setProjectionMatrix(camera.combined() ) ;

how does viewport have nothing to do with stretching the game to fit the screen, when viewport does exactly that? I do realize however, that there are multiple different ways to achieve the same results with libgdx, so it can be confusing at times.

Because even if he has a camera with a viewport applied, if he does not set the projection of the batch to the camera or will not render properly.

I see, perhaps I don’t know about that because I am using a stage which has a batch, camera and viewport attached to it. Just setting a viewport size is all I need to do to get it to render properly, seems that creating the stage automatically sets up some additional camera stuff.

Viewport does not seem to be an existing class in the current Version of LibGDX I’m using. :-X

[quote]This had nothing to do with viewport though, however do look into this for maintaining aspect ratio and desires resolution over all devices.

What you need to do is set the sprite batch projection to the cameras using:
[/quote]
I’m using screens as a way of organizing which state my game is in, would this mean I would have to create a camera class in each of the screens and set the batches to camera.combined? I also have many entity classes with their own Sprite Batches so I would then have to pass the Sprite Batches’ from the Screen classes to be able to make sure every graphics thingamajig is modified correctly?