How to make full screen in Android 4.0

夙愿已清 提交于 2019-12-03 05:17:56

问题


Android 4.0 phones only have virtual buttons, which actually go invisible when playing youtube/video at fullscreen (the video portion takes over where the buttons are).

I want to do this, but haven't found a way.

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

or

requestWindowFeature(Window.FEATURE_NO_TITLE); 
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

do not cover the virtual buttons.

Here is an example that shows the type of full screen I'm talking about:

http://www.youtube.com/watch?v=Lw_O1JpmPns


回答1:


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)




回答2:


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" >



回答3:


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).




回答4:


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.



来源:https://stackoverflow.com/questions/8681177/how-to-make-full-screen-in-android-4-0

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