【问题标题】:Hide status bar when using a YoutubeFragment (YoutubePlayer android API)使用 YoutubeFragment (YoutubePlayer android API) 时隐藏状态栏
【发布时间】:2014-04-25 00:31:18
【问题描述】:

我有一个全屏项目,并且正在使用隐藏状态栏

        getWindow ().setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

在主Activity的onCreate中。

这可以正常工作,并且可以很好地隐藏状态栏,直到我添加 YoutubeFragment 并播放视频。视频加载的那一刻,状态栏下降,非常烦人。我尝试在 onInitializationSuccess 侦听器上设置标志,但没有骰子。该文档根本没有提及任何非全屏布局更改的状态栏:https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubePlayerFragment

有人有什么想法吗?

提前致谢。

【问题讨论】:

    标签: android android-youtube-api android-notification-bar


    【解决方案1】:

    不知道能不能在manifest里面放一个隐藏action bar。

    不过试试Activity类的这个功能

    getActionBar().hide();
    

    【讨论】:

      【解决方案2】:

      我正在使用 android 4.4.2 设备进行测试。对于 4.1+ 或更高版本,还有另一种动态隐藏状态栏的方法:http://developer.android.com/training/system-ui/status.html#41

          //4.1+ Specific hiding of status bar
      
          View decorView = getWindow().getDecorView();
          int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
          decorView.setSystemUiVisibility(uiOptions);
      

      我没有遇到添加 YoutubeFragment 时弹出状态栏的问题。为什么旧代码无法与 YoutubeFragments 一起使用,甚至无法将 Theme 设置为

       android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen"
      

      ,我不知道。

      【讨论】:

        猜你喜欢
        • 2016-05-10
        • 2017-08-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多