I came up with a problem right now when my game is almost finish. The problem is that I want the player to be able to play both in landscape mode and portrait. How the player change mode is simple. Before he start the game, a message comes up and lets him decide witch mode he wants to play. Here comes the problem. In the Manifest.xml file – you can tell the game to play on just portrait or just landscape mode. So I wanna use a boolean to show witch one of the modes the player chose. But in xml, there is no “if” that can change the game depence the players choise. So how do I do to change the mode to the that one that the player choose?
Share
Just use
context.setRequestedOrientation()and place your xml inside thelayout-landorlayout-portfolder.Android will automatically choose the right layout depending on parameter
SCREEN_ORIENTATION_LANDSCAPEorSCREEN_ORIENTATION_PORTRAIT