Android – keep the screen always in landscape mode

By -

Problem: How do I keep the screen always in Landscape mode?

Description:
I have an activity which should always be displayed in Landscape mode. So I added

android:screenOrientation="landscape"

But When the tablet is moved upside done (inverted or rotate the device by 180 degrees) the application doesnt flip but stays locked in the same position. But in landscape mode itself it should work with either edge in the bottom.

To better understand what I am saying,

  1. Load the app.
  2. Now flip it – Camera on the bottom for your device (say for example tablet).
  3. The screen doesnt flip like it should. The screen is locked in the same orientation as if the camera was up.

Now Try the same experiment on your home screen (Native home of android) and you will see it flip.

Solution:
Just add this orientation instead of android:screenOrientation=”landscape”:

android:screenOrientation="sensorLandscape"
// for both landscape and reverseLandscape

CEO & Co-Founder at SolGuruz® | Organiser @ GDG Ahmedabad | Top 0.1% over StackOverflow | 15+ years experienced Tech Consultant | Helping startups with Custom Software Development

Loading Facebook Comments ...
Loading Disqus Comments ...