Making an Android app fullscreen with Cordova

前端 未结 2 537
不知归路
不知归路 2020-12-17 01:27

I\'m a newcomer to Cordova, and am trying to make an app that appears full screen (hiding the taskbar at the bottom of Android).

I have looked online and there seem

2条回答
  •  情话喂你
    2020-12-17 02:20

    Unfortunately the Plugin didn't work for me, so I managed it with these steps:

    Add the Fullscreen preference in your config.xml file:

    
    

    Find the AndroidManifest.xml in platforms/android/ and add the Fullscreen Theme

    
        
            
    

    Finally, and this was the harder step, use the Immersive Full-Screen Mode. The only way I got it to work was directly extending the CordovaApp.java file in plattforms/android/src/com/example/hello/

    ...
    import android.view.View;
    
    //Cordova onCreate function....
    //public void onCreate()
    //...    
    
    //this is the important thing:
    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
      super.onWindowFocusChanged(hasFocus);
      View decorView = getWindow().getDecorView();
      if(hasFocus) {
            decorView.setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        }
    }
    

    I am not an Java Developer (jet) so I can't explain in detail what happend, but it seems to work. Keep in mind that Cordova creates the platforms/android folder, so its possible that it will be overwritten by some actions.

提交回复
热议问题