Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix screen orientation to portrait for my whole PhoneGap app

How to configure the Phonegap app to be fixed to only portrait mode, I there any possibility to do it with CSS or JavaScript so that I should be able to get the consistent behaviour across the platforms

I found this useful post detecting-displays-orientation-change-on-mobile-devices-with-accelerometer-a-platform-indipendent-approach

Here it is explained how to detect the orientation, but I need to configure it

Is it possible through CSS3 Media queries?

like image 964
Vinayak Bevinakatti Avatar asked Sep 20 '11 09:09

Vinayak Bevinakatti


People also ask

How do I change the default orientation in Android Studio?

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.


2 Answers

To fix your orientation in portrait mode just add the below line in your activity tag in AndroidManifest.xml file:

 android:screenOrientation="portrait"

or this in the activity class:

setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
like image 172
Maulik J Avatar answered Oct 15 '22 17:10

Maulik J


Actually you can use config.xml to set it to all devices if you're using PhoneGap Build...
Set the propertie: orientation with possible values default, landscape, or portrait
example:

< preference name="orientation" value="landscape" />

*please note that default means both landscape and portrait are enabled.

Source:
https://build.phonegap.com/docs/config-xml

like image 28
Diego Avatar answered Oct 15 '22 17:10

Diego