George N
George N

Reputation: 161

Locking the orientation of my android phone

I'm writing an Android app. How do I lock the orientation of the phone in the portrait mode?

Upvotes: 0

Views: 1446

Answers (2)

JM Macariola
JM Macariola

Reputation: 103

the android:screenOrientation="portrait" would be the way to go but if you want to do it programmatically, just call setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); in your onCreate()

Upvotes: 0

Matt Pope
Matt Pope

Reputation: 167

In your AndroidManifest.xml add the following tag android:screenOrientation="portrait" in the Activity block. A sample would be:

    <activity android:name=".FusionDrone"
        android:label="@string/app_name"
        android:configChanges="orientation"
        android:screenOrientation="portrait"
        android:theme="@android:style/Theme.Translucent">

Upvotes: 1

Related Questions