android 横竖屏切换
< activity android:name="MyActivity" android:configChanges="orientation|keyboardHidden">
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
//加入横屏要处理的代码
}else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
//加入竖屏要处理的代码
}
}
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
//加入横屏要处理的代码
}else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
//加入竖屏要处理的代码
}
}
静以修身,俭以养德。
posted on 2016-09-05 13:20 miaozhenzhong 阅读(113) 评论(0) 编辑 收藏 举报