1 <?xml version="1.0" encoding="utf-8"?> 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android" 3 package="com.sowsceo.rnadomsows"> 4 5 <application 6 android:allowBackup="true" 7 android:icon="@mipmap/ic_launcher" 8 android:label="@string/app_name" 9 android:screenOrientation="landscape" 10 android:supportsRtl="true" 11 android:theme="@style/AppTheme" 12 > 13 <activity 14 android:name=".MainActivity" 15 android:launchMode="singleTask" 16 android:screenOrientation="landscape"> 17 <intent-filter> 18 <action android:name="android.intent.action.MAIN" /> 19 20 <category android:name="android.intent.category.LAUNCHER" /> 21 </intent-filter> 22 </activity> 23 <activity android:name=".produce.ActivityRandom" /> 24 </application> 25 </manifest>
強制每個activity的橫屏或縱屏,也就是說,當用戶設置手機可以“自動旋轉”時,對於已經強制橫屏或縱屏的界面無效,
問題:如何讓activiy的界面強制呢!
解答:
在AndroidManifest.xml文件中,對<activity></activity>進行設置
1 <activity android:name=".produce.ActivityRandom" 2 android:launchMode="singleTask" 3 android:screenOrientation="landscape"/> 4 5 launchMode/screenOrientation 兩種參數的設置,缺一不可 6 7 android:launchMode="singleTask" 8 參數說明,詳細點擊它 http://2960629.blog.51cto.com/2950629/701227 9 10 android:screenOrientation="landscape" 11 landscape是橫向,portrait是縱向