AndroidManifest设置横竖屏 (Activity 节点) android:screenOrientation="option" option = [ "unspecified" "landscape" "portrait" ] 代码设置横竖屏 (Activity) setRequestedOrientation(int requestedOrientation) android.content.pm.ActivityInfo [ ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ] 备注:Manifest设置了横竖屏属性,在代码中是可以更改的
转屏会调用Activity的onCreate()生命周期方法 禁止onCreate方法的调用要在Manifest中增加android:configChanges="orientation" Android 3.2(API level 13)以后还要增加 screenSize (android:configChanges="orientation|screenSize") Activity中对应的调用方法为 @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); } // 此方法处理一些转屏后的操作 android.content.res.Configuration [ Configuration.ORIENTATION_UNDEFINED Configuration.ORIENTATION_LANDSCAPE Configuration.ORIENTATION_PORTRAIT ]