Android 禁止响应屏幕翻转
app安装到手机后,翻转屏幕,页面可能出现变型,弹出框消失等问题,禁止屏幕翻转:
要在androidmanifest.xml 中加入 android:screenOrientation="portrait"
需要在application 标签属性加入,也需要在所有activity标签属性加入
<application android:allowBackup="true" android:icon="@drawable/ui" android:label="@string/app_name" android:theme="@style/AppTheme" android:screenOrientation="portrait"> <activity android:name="com.pccw.barcodescanner.MainActivity" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.pccw.barcodescanner.ServiceConfigActivity" android:label="@string/main_config" android:theme="@android:style/Theme.NoTitleBar" android:screenOrientation="portrait" > </activity> <activity android:name="com.pccw.barcodescanner.OnlineActivity" android:label="@string/main_Rbonline" android:theme="@android:style/Theme.NoTitleBar" android:screenOrientation="portrait" > </activity>