【问题标题】:android full screen an activity and hide key barandroid全屏活动并隐藏键栏
【发布时间】:2014-03-25 17:26:42
【问题描述】:

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

我尝试使用

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

但它只是消失了动作栏,我想同时消失动作栏和 android 默认键栏(主页按钮、返回和另一个)

【问题讨论】:

    标签: java android android-fullscreen


    【解决方案1】:

    如果您的目标是 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 了解更多详细信息

    【讨论】:

    • 但我怎样才能保留这个?并再次隐藏它?我覆盖了 onTouch 事件,但键栏仍然出现。 :(
    • 从开发者网站中给出的观点...我认为这是不可能的。你检查过这个链接吗developer.android.com/training/system-ui/visibility.html
    • 是的!我找到了答案,我们应该把它放在 onResume no onTouch !再次感谢您的帮助!
    • 我不知道这是否有助于您的查询,因为隐藏栏会停止您的导航。让我们看看是否有人提出了更好的解决方案
    • 虽然提到针对 android 4.0 为什么会出现 View.SYSTEM_UI_FLAG_FULLSCREEN 警告?
    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-06
      • 2011-01-23
      相关资源
      最近更新 更多