android 横竖屏切换

来源:互联网 发布:半条命gman知乎 编辑:程序博客网 时间:2024/05/29 19:46
< 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) {   
           //加入竖屏要处理的代码  
    }   

0 0
原创粉丝点击