【问题标题】:Cordova Android app Navigation Bar and Status Bar flicker or turn solid whiteCordova Android 应用程序导航栏和状态栏闪烁或变为纯白色
【发布时间】:2021-11-01 09:05:14
【问题描述】:

我们正在 Zebra TC-57 设备上使用 Cordova 9.0 将我们的 Web 应用程序部署到 Android 8,该设备具有软导航栏(返回、主页、最近软按钮),并且我们看到的屏幕区域是通常由状态栏(顶部)和导航栏(底部)占据,快速闪烁或闪烁,有时会变成纯白色,导致状态栏和导航栏都无法正确呈现。

我们不希望应用占用全屏,我们只希望它适当地占据状态栏和导航栏之间的屏幕空间。

有解决办法吗?

【问题讨论】:

    标签: android cordova ionic-framework statusbar navigationbar


    【解决方案1】:

    修复

    AndroidManifest.xml <activity/> 元素中,将@android:theme 更改为@android:style/Theme.Translucent 的值,为我们解决了这个问题:

    Cordova 生成 AndroidManifest.xml

    <manifest ...>
        ...
        <activity 
    android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" 
        android:label="@string/activity_name" 
        android:launchMode="singleTop" 
        android:name="MainActivity" 
    
        android:theme="@android:style/Theme.Translucent" 
    
        android:windowSoftInputMode="adjustResize">
        ...
        </activity>
        ...
    </manifest>
    

    自动化此更改以便您不必修改 Cordova 生成的 AndroidManifest.xml 文件的最简单方法是简单地将 edit-config 元素添加到您的 Cordova config.xml 文件的 android &lt;platform&gt; 部分(感谢@simon-ludwig 提供info):

    Cordova config.xml 平台部分

        <platform name="android">
            <edit-config file="AndroidManifest.xml" target="/manifest/application/activity[@android:label='@string/activity_name']" mode="merge">
                <activity android:theme="@android:style/Theme.Translucent"></activity>
            </edit-config>
            <!-- Other Android platform settings -->
        </platform>
    

    TLDR;

    在某些设备上,似乎与 Cordova android 生成的默认 Android 主题不兼容。它为AndroidManifest.xml 中的android:theme 属性指定的值是@android:style/Theme.DeviceDefault.NoActionBar

    <manifest ...>
        ...
        <activity 
    android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" 
        android:label="@string/activity_name" 
        android:launchMode="singleTop" 
        android:name="MainActivity" 
        
        android:theme="@android:style/Theme.DeviceDefault.NoActionBar" 
        
        android:windowSoftInputMode="adjustResize">
        ...
        </activity>
        ...
    </manifest>
    

    在 Android 开发者网站上记录了许多主题选项 here。我们发现至少在运行 Android 8 时适用于 TC-57 的是 android:theme="@android:style/Theme.Translucent" 的值

    【讨论】:

    • 在 Android 8 上的 TC51 和 TC52 上存在同样的问题。但我已经有了 @android:style/Theme.Translucent;还有其他提示吗?
    • @esskar: 你在安卓网站上尝试过here 的其他主题吗?搜索“主题_”页面。
    【解决方案2】:

    将 GPU 渲染器设置为 SKIA 有助于 TC56 - 但您需要访问开发者选项

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多