2016-10-30 9 views
5

Das einzige, was ich finden kann, ist diese verwenden:Wie wird die App so eingestellt, dass sie nur im Hochformat angezeigt wird?

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

aber es bleibt wie normal. Mein 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> 

Antwort

16

Wie in der Frage gesehen: I want my android application to be only run in portrait mode?

sollten Sie setzen die configChanges und screenOrientation Flags für jede Aktivität, und nicht an der Wurzel Ihrer manifestieren.

So sollte es so aussehen:

<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> 
0

Die android:screenOrientation muss in <activity> Block sein. Auch android:configChanges gilt nicht für <application> aber <activity> auch.

Verwandte Themen