android全屏活动并隐藏键栏

时间:2014-03-25 17:26:42

标签: java android android-fullscreen

我是android编程的新手! 我想要像Hill Climb Racing这样的全屏图像(如下所示)

Hill Climb Racing

我尝试使用

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

但它只是消失动作栏,我想消失动作栏和Android默认键栏(主页按钮,后面和另一个)

2 个答案:

答案 0 :(得分:9)

如果您的目标是Android 4.0及更高版本

View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
              | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);

检查此developer site以获取更多详细信息

答案 1 :(得分:3)

在清单上的活动中尝试此操作

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