Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to lock phone orientation in Android to prevent landscape mode

Tags:

android

Is this possible to do? Landscape mode distorts the background image, and therefore I would like to lock orientation to vertical on phones with accelerometers.

Thanks.

like image 664
Allen Gingrich Avatar asked Sep 04 '10 04:09

Allen Gingrich


1 Answers

You can force the screen orientation to always be portrait for individual activities in the manifest. You use the

android:screenOrientation

attribute with the value "portrait" in each of the activities you want to always have the portrait orientation.

<activity android:name=".MyActivity" android:screenOrientation="portrait">
...
</activity>
like image 51
Brian Avatar answered Sep 24 '22 02:09

Brian