I have developed a game in libgdx. I worked for long and after finishing, I found that the game runs perfectly only on devices with resolution 800 × 480. I found this solution:

    <!-- all small size screens -->
    <screen android:screenSize="small" android:screenDensity="ldpi" />
    <screen android:screenSize="small" android:screenDensity="mdpi" />
    <screen android:screenSize="small" android:screenDensity="hdpi" />
    <screen android:screenSize="small" android:screenDensity="xhdpi" />
    <!-- all normal size screens -->
    <screen android:screenSize="normal" android:screenDensity="ldpi" />
    <screen android:screenSize="normal" android:screenDensity="mdpi" />
    <screen android:screenSize="normal" android:screenDensity="hdpi" />
    <screen android:screenSize="normal" android:screenDensity="xhdpi" />

But it allows various other resolutions too; Is there any way that I can publish my game only for 800 × 480 resolution?

  • 1
    \$\begingroup\$ Why would you want to do that? If your game doesn't work properly with other resolutions, fix it. \$\endgroup\$ – aaaaaaaaaaaa Apr 13 '14 at 7:41
  • 1
    \$\begingroup\$ Are you using libgdx cameras? If you would use those you could easily make it look nicely on any size screen. If you only target 800x480 resolution you are going to lose a lot of potential people to install your game \$\endgroup\$ – KodyVanRy Apr 15 '14 at 14:35

There are ways to restrict the screen types your app will be distributed to, as described here, but I don't think it gets as specific as you want, and I'm not sure why you would want to make it that specific. It would restrict your market to a very tiny subset of all Android users. You can put a warning in the description that it only works on certain screen resolutions, if you want, or you can change things to support a larger set of resolutions.

In the latter case, there are plenty of other questions and answers on this site addressing that issue. I recommend this answer in particular, to get you started.


I use a framework called MTX that works on top of LibGDX, so my answer may be different. I am not saying to redo your whole game in MTX, that would be silly. However the framework is open-source, so you can figure out how everything is done with a little bit of looking.

You mainly need to look at 2 main things:

  • Resolution
  • Aspect Ratio

You mentioned a target resolution of 800 x 480, therefore the aspect ratio is ~1.666667. I would set these in some global class made just for resolution:


Now we need the current information:

CURRENT_ASPECT_RATIO = Gdx.graphics.getWidth() / Gdx.graphics.getHeight();

What we want to do here is to scale everything while maintaining the aspect ratio. So not every screen is going to be 5:3 specifically, but we can fit the game into 5:3 as best we can and simply constrain the gameplay elements within that area. Anything outside of that area can be background so as not to waste the space.

I am assuming that any device is forced into landscape mode.


    //Filler is on top and bottom
    WORLD_SCALE = Gdx.graphics.getWidth();
    // Filler is on left and right
    WORLD_SCALE = Gdx.graphics.getHeight() / TARGET_HEIGHT;

What this does is finds out your working area. It will fit to whatever size screen, either by length or by height. By applying world scale, we also ensure that your objects scale up for larger screens as well.

For example, my phone has a screen that is 1920x1080. It has a higher aspect ratio than 800x540, and therefore we need to put some bars on the side. This would give me a WORLD_SCALE of 2, a WORLD_HEIGHT of 1080, and a WORLD_WIDTH of 1600, trimming 160 pixels off both sides.

Now it's too late at night for me to go into detail about how to use these values specifically, but it's pretty straightforward. You construct a Viewport object using the newfound values to size and center it. Ensure that your worldWidth and worldHeight for the viewport match your TARGET_WIDTH and TARGET_HEIGHT. Then you can construct your Stage using the new Viewport.

This stage should now be correctly fitted to maintain your desired aspect ratio, while scaling everything to fit the screen as much as possible without messing up the aspect ratio of your game.

  • \$\begingroup\$ Actually I am using MTX too. It's fine for landscape mode... runs well on all devices. But if I am trying to create a portrait game.. MTX works too bad. Can you tell me on what should be target_width & target_height in AppSettings. \$\endgroup\$ – Vishal Kumar Apr 16 '14 at 17:56
  • \$\begingroup\$ My games run in portrait mode and I have no issue. Make sure to set the proper target_width and target_height, and also make sure to change android:screenOrientation="landscape" to android:screenOrientation="portrait" in your AndroidManifest.xml. \$\endgroup\$ – user39686 Apr 16 '14 at 21:56
  • \$\begingroup\$ Actually if you want to see an example of a Live Wallpaper that I published, here's the full source code and eclipse project. It uses LibGDX 0.9.9 and MTX 2.1, so if your project uses newer version I would suggest just copy-pasta anything you need. \$\endgroup\$ – user39686 Apr 16 '14 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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