横竖屏切换,不重新加载
1、activity声明android:configChanges="orientation|keyboardHidden|screenSize"
Up to API 13 there was a new value to the configChanges attribute, screenSize
So if you‘re using large screens make sure to add screenSize in your configChanges attribute:
android:configChanges="orientation|keyboardHidden|screenSize"
2、Activity重写onConfigurationChanged:
public
void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig); }
--------------------------------------------------------------------------------------------
代码切换横竖屏
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);