繁体   English   中英

防止应用覆盖 Android 通知栏

[英]Prevent app from overriding the Android notification bar

我有以下简单的布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
</android.support.constraint.ConstraintLayout>

如何让通知永久显示在我的应用程序中? 我的 SDK 版本是 27。我已经尝试了很多可用的解决方案,但似乎都没有奏效。

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

我的 styles.xml:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:statusBarColor">@color/colorPrimaryDark</item>
        <item name="android:windowLightStatusBar">true</item>
    </style>

</resources>

看起来 SceneForm 的 BaseARFragment 通过 OnWindowFocusChangeListener 使主机 Activity 使用沉浸式模式。 认为您应该能够添加自己的 OnWindowFocusChangeListener 并且它将在另一个之后调用,因此您可以覆盖此行为。

arFragment.arSceneView?.viewTreeObserver.addOnWindowFocusChangeListener { hasFocus -> 
    if (hasFocus) {
        window.decorView
          .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
    }
}

阅读系统 UI 标志以确定您真正想要的标志。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM