1

我是 Android 开发的新手。我在我的 android 应用程序中实现了一个选项,用于在全屏和普通屏幕之间切换。下面是我的代码。但是我遇到了一个问题。当我将我的应用程序切换到全屏模式时,我的活动上的所有滚动视图都会停止滚动。当我切换回正常屏幕时,所有滚动视图都可以正常工作。帮我。

//Shared Preferences
    SharedPreferences screenPreference = getSharedPreferences("MyAppSettings", MODE_PRIVATE);
    int ScreenFlag = screenPreference.getInt("ScreenFlag", 0);
    SharedPreferences.Editor editor = screenPreference.edit();
    switch(ScreenFlag)
    {
    case 0:     //set preference ScreenFlag, app running first time
    case 2:     //Full screen - OFF
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        editor.putInt("ScreenFlag", 2);
        editor.commit();
        break;
    case 1:     //Full screen - ONN
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        editor.putInt("ScreenFlag", 1);
        editor.commit();
        break;
    default:
        break;
    }
    setContentView(R.layout.activity_main);
    //end - Shared Preferences
4

0 回答 0