1,禁止横竖屏切换
在配置文件中写死
- android:screenOrientation="landscape"
- android:screenOrientation="portrait"
2,横竖屏切换不重启Activity
在配置文件中声明程序自己处理,在onConfigurationChanged()中处理
- android:configChanges="orientation"
- android:configChanges="orientation|screenSize"
3,动态设置横竖屏
- if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE){
- setRequestedOrientation(Configuration.ORIENTATION_PORTRAIT);
- }else{
- setRequestedOrientation(Configuration.ORIENTATION_LANDSCAPE);
- }