【问题标题】:How to hide Android titlebar when Google Play Games is initialising?如何在 Google Play 游戏初始化时隐藏 Android 标题栏?
【发布时间】:2019-01-25 23:42:59
【问题描述】:

当我初始化 Google Play 游戏时,当我的游戏已加载,并且“连接到 Google Play 游戏”窗口在开始时出现 - Android 标题栏也会暂时出现。一旦 GPG 登录窗口消失,它就会消失。我该如何阻止这种情况发生?在我的游戏清单中,我在活动标签中设置了以下样式:

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

这显然有效,因为我在游戏运行时看不到工具栏。我查看了 Google Play 游戏服务 GameBaseUtils 清单,它没有任何活动标签,因此我将 NoTitleBar 样式添加到应用程序标签中,如下所示:

<application
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
    <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
</application>

但是,当游戏加载和 Google Play 游戏初始化时,标题栏仍会(暂时)显示。有什么办法可以在 GPG 初始化时完全去掉标题栏?

【问题讨论】:

    标签: android libgdx google-play-games


    【解决方案1】:

    在您的 onCreate() 方法中执行此操作。 干杯!

    //Remove title bar
    
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    
    //Remove notification bar
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    
    //set content view AFTER ABOVE sequence (to avoid crash)
    this.setContentView(R.layout.your_layout_name_here);
    

    【讨论】:

    • 我将您的代码添加到 AndroidLauncher 中的 onCreate 方法中,但它不起作用。 SetContentView 不与 libGDX 项目一起使用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多