横竖屏切换

我是参考这篇文章 :https://www.jianshu.com/p/dbc7e81aead2

主要是布局分横竖屏

横竖屏切换_第1张图片

 

然后再java代码 

 Configuration cf = this.getResources().getConfiguration();
        int ori = cf.orientation;
        if (ori == cf.ORIENTATION_LANDSCAPE) {
            setContentView(R.layout.feedback_list);
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else if (ori == cf.ORIENTATION_PORTRAIT) {
            setContentView(R.layout.feedback_list);
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//竖屏
        }

  

你可能感兴趣的:(横竖屏切换)