Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set orientation to landscape in android on both sides

I am working in an android application in 2.2 and I want to set my application in landscape mode.

For that I added in my manifest with every activity tag android:screenOrientation="landscape" and it worked fine.

But it comes only in one side. If I turn the device again upside down it fit in the same position in landscape mode. How can I have landscape mode in both the side of the device. Please help me.

Thanks in advance.

like image 948
Arun Avatar asked Jun 15 '12 05:06

Arun


2 Answers

I am not sure about 2.2 but if you're building your app for Android 2.3 and newer you can set in activity manifest

android:screenOrientation="sensorLandscape"

If you're building your app for Android 2.2 and older but want to run it on Android 2.3 and newer as a "sensorLandscape" configuration, you could try something like this

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    }
like image 130
Vipul Avatar answered Dec 07 '22 22:12

Vipul


Try this

android:screenOrientation="reverseLandscape"
like image 32
Roman Black Avatar answered Dec 07 '22 22:12

Roman Black