Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How to Disable landscape mode in Android?

How can I disable landscape mode for some of the views in my Android app?
by

2 Answers

rahul07
Add this android:screenOrientation="portrait" in your manifest file where you declare your activity like this

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

If you want to do using java code try

setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
before you call setContentView method for your activity in onCreate().

Hope this help and easily understandable for all...
kshitijrana14
Add this android:screenOrientation="portrait" in your manifest file where you declare your activity like this
<activity android:name=".yourActivity"
....
android:screenOrientation="portrait" />

If you want to do using java code try
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 

before you call setContentView method for your activity in onCreate().
Hope this help and easily understandable for all...

Login / Signup to Answer the Question.