3

尝试以纵向/横向/反向纵向/反向横向旋转应用程序。它的旋转应用程序仅在三种模式下,但无法以反向纵向旋转应用程序。

我的代码:

public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        if (isRecording == false) {
            Log.v("new orientation", "yes");
            if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {

                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
                wholeView.setOrientation(1);
            }
            else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {

                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
                wholeView.setOrientation(0);
            }else if (newConfig.orientation == Configuration.ORIENTATION_UNDEFINED) {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
                wholeView.setOrientation(0);
            }else if (newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT)
            {

                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
                wholeView.setOrientation(LinearLayout.VERTICAL);
            }
4

0 回答 0