Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set app to be portrait only? [duplicate]

The only thing I can find is to use this:

android:configChanges="orientation"
    android:screenOrientation="portrait"

but it stays as normal. My manifest:

?xml version="1.0" encoding="utf-8"?>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:configChanges="orientation"
    android:screenOrientation="portrait"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

like image 329
Synnipoe Avatar asked Oct 30 '16 19:10

Synnipoe


People also ask

How do I make my IOS app portrait only?

Go to Targets -> General, scroll down and you can select the Orientation as portrait only.

How do you force a portrait?

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.


1 Answers

As seen in the question: I want my android application to be only run in portrait mode?

You should set the configChanges and screenOrientation flags for every activity, and not at the root of your manifest.

So it should look like this:

<activity android:name=".MainActivity"
  android:configChanges="orientation"
  android:screenOrientation="portrait">
    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>

        <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
</activity>
like image 69
Mor Paz Avatar answered Oct 19 '22 05:10

Mor Paz