I have multiple classes that implement Screen.

I want to, say, have the Main Menu screen portrait, then the Play Screen landscape. Is there anyway of changing the orientation dynamically?

I thought I could just start another Activity and have the Play Screen extend Game. And the new Activity would intialize the Play Screen. But it appears that you can't call startActivity or the like, obviously, as LibGDX is platform independent.

I use Gdx.graphics.getWidth() and Gdx.graphics.getHeight() to align Sprites and Actors so it looks "right" on different devices.

I've also tried swapping the Gdx.graphics.getWidth() and Gdx.graphics.getHeight(), respectively, but can't seem to get the position of sprites and actors correct.


1 Answer 1


I figured out how to do it.

I used an interface as shown at this link

Basically, I created an interface in the core project, then for each back-end project I implements my interface.

To change the orientation in Android is simple as shown here

That is, setRequestedOrientation(ActivityInfo.<THE_ORIENTATION>)

  • 1
    \$\begingroup\$ This answer would be better if it included the relevant code, so that even if the two links break the information is preserved. \$\endgroup\$
    – DMGregory
    Mar 4, 2021 at 12:35

You must log in to answer this question.

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