Wednesday, July 31, 2013

Show Activity in Portrait or Landscape mode only

In Android, some times  we need to show an Activity/Screen in portrait or Landscape mode only. Specially while developing game, we want a particular game to be played in Landscape or Portfrait mode only.

for this we need to set the  android:screenOrientation  attribute in manifest

To show the Screen/Activity in Landscape mode only

 <activity android:name=".MainActivity"
           android:screenOrientation="landscape"/>


To show the Screen/Activity in Portrait mode only.

 <activity android:name=".MainActivity"
           android:screenOrientation="portrait"/>

7 comments: