Quantcast
Viewing all articles
Browse latest Browse all 35

How to set the screen orientation to Portrait for an Android Activity?

By default an Activity support both Portrait and Landscape mode. On changing the orientation of the device, view rotates accordingly. However in certain apps we may want to limit the orientation to Portrait or Landscape and we can do the same by specifying the android attribute screenOrientation to portrait or landscape as part of the Activity definition:

Example:

<activity android:name=".activity.AudioPlayerScreen"
android:label="Audio Player"android:screenOrientation="portrait"]]>
<intent-filter]]>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT"/>

This will set the orientation of Audio Player Screen to Portrait mode only.


Viewing all articles
Browse latest Browse all 35

Trending Articles