2017-12-03 86 views
0

當我創建一個應用程序我沒有肖像模式的問題,但是當我把谷歌地圖它允許查看橫向模式。這裏是我的代碼:如何鎖定旋轉?

Android清單:

<activity 
     android:name=".MainActivity" 
     android:label="@string/app_name" 
     android:screenOrientation="sensorPortrait" 
     android:configChanges="orientation|keyboardHidden|keyboard"> 

MainActivity.java:

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); 

請幫我解決了英文不好

+0

如果你想鎖定它使用'SCREEN_ORIENTATION_PORTRAIT' – Oleg

+0

我已經試過了,但仍允許在橫向模式下的應用程序 – LogicTrix

+0

哦,你想鎖定不同的應用程序?我不認爲這是可能的。 – Oleg

回答

0

試試這個問題和遺憾在AndroidManifest.xml以下鎖定您的MainActivity活動,無需寫任何東西在MainActivity.java文件...

<activity 
      android:name=".MainActivity" 
      android:label="@string/app_name" 
      android:screenOrientation="portrait" 
      android:configChanges="orientation|keyboardHidden|keyboard">