Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want my android application to be only run in portrait mode?

I want my android application to be only run in portrait mode? How can I do that?

like image 568
James Avatar asked Sep 16 '10 04:09

James


People also ask

How do I force an app to stay in portrait mode?

On the main screen of Rotation Manager, select an orientation by tapping on either the vertical or horizontal icons next to a specific app to lock it into either landscape or portrait mode. Highlighting both icons will allow that particular app to auto-rotate.


3 Answers

In the manifest, set this for all your activities:

<activity android:name=".YourActivity"
    android:configChanges="orientation"
    android:screenOrientation="portrait"/>

Let me explain:

  • With android:configChanges="orientation" you tell Android that you will be responsible of the changes of orientation.
  • android:screenOrientation="portrait" you set the default orientation mode.
like image 106
Cristian Avatar answered Oct 22 '22 21:10

Cristian


In Android Manifest File, put attribute for your <activity> that android:screenOrientation="portrait"

like image 42
Praveen Avatar answered Oct 22 '22 20:10

Praveen


There are two ways,

  1. Add android:screenOrientation="portrait" for each Activity in Manifest File
  2. Add this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); in each java file.
like image 27
Android Code Solution Avatar answered Oct 22 '22 20:10

Android Code Solution