How to make full screen in Android 4.0

隐身守侯 提交于 2019-12-02 18:34:30

Okay, I added this SYSTEM_UI_FLAG_HIDE_NAVIGATION flag to my video activity and that hid the virtual buttons.

WebView view = new WebView(this);
view.setSystemUiVisibility(WebView.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

Another choice is to use the SYSTEM_UI_FLAG_LOW_PROFILE flag. This doesn't hide the buttons though. Instead it makes the buttons go to "Low Profile" mode (basically turns them into little dots)

This works on my device but not in the emulator. Add this tho your activity in AndroidManifest.xml:

    <activity ...
        android:theme="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen" >

Inside the onCreate() of your Activity, add this:

this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
     WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.getWindow().getDecorView()
    .setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

Worked well for me (but is not Honeycomb-compatible).

To make the buttons completely invisible, you should do

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
         WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.getWindow().getDecorView()
        .setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION 
               | View.SYSTEM_UI_FLAG_IMMERSIVE);

The buttons would not use any space on the screen, unless you swipe up from the bottom of the screen. Notice that you need to target at SDK version 19 for this to work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!