Praveen
Praveen

Reputation: 91175

How can the landscape screen orientation be restricted in android?

How can the landscape screen orientation be restricted in android?

Upvotes: 7

Views: 7350

Answers (2)

Mark B
Mark B

Reputation: 200486

Your question is very short, but I believe you are asking how to restrict an Activity's display to a specific orientation. To do so try using the android:screenOrientation in the <Activity> tag(s) in your Manifest file.

https://developer.android.com/guide/topics/manifest/activity-element.html#screen

Upvotes: 16

Vishal Khakhkhar
Vishal Khakhkhar

Reputation: 2116

You can set the Activity parameters as defined below..

<activity android:allowTaskReparenting=["true" | "false"]
          android:alwaysRetainTaskState=["true" | "false"]
          android:clearTaskOnLaunch=["true" | "false"]
          android:configChanges=["mcc", "mnc", "locale",
                                 "touchscreen", "keyboard", "keyboardHidden",
                                 "navigation", "orientation", "fontScale"]
          android:enabled=["true" | "false"]
          android:excludeFromRecents=["true" | "false"]
          android:exported=["true" | "false"]
          android:finishOnTaskLaunch=["true" | "false"]
          android:icon="drawable resource"
          android:label="string resource"
          android:launchMode=["multiple" | "singleTop" |
                              "singleTask" | "singleInstance"]
          android:multiprocess=["true" | "false"]
          android:name="string"
          android:noHistory=["true" | "false"]  
          android:permission="string"
          android:process="string"
          android:screenOrientation=["unspecified" | "user" | "behind" |
                                     "landscape" | "portrait" |
                                     "sensor" | "nosensor"]
          android:stateNotNeeded=["true" | "false"]
          android:taskAffinity="string"
          android:theme="resource or theme"
          android:windowSoftInputMode=["stateUnspecified",
                                       "stateUnchanged", "stateHidden",
                                       "stateAlwaysHidden", "stateVisible",
                                       "stateAlwaysVisible", "adjustUnspecified",
                                       "adjustResize", "adjustPan"] >   
    . . .
</activity>

Upvotes: 7

Related Questions