angular - Nativescript Angular Android 应用程序强制灯光模式不起作用

标签 angular nativescript cross-platform nativescript-angular angular-nativescript

我在 API 29 中使用 Angular 构建的 NativeScript Android 应用程序无法从 Values-v29 文件夹获取 styles.xml 设置。

<style name="AppThemeBase29" parent="AppThemeBase21">
    <item name="android:forceDarkAllowed">false</item>
</style>

values-v29 文件夹仅包含 styles.xml 文件。我已将 forceDarkAllowed 设置为 false,如上所示。除此之外,我还在 main.tns.ts 文件中动态设置了主题:

Theme.setMode(Theme.Light);

我错过了什么?它通过更改 Info.plist 文件在 IOS 上运行。

native script version: 6.5.0 angular version: 8

最佳答案

对于 Android,您可能必须在 main.ts 中实现应用程序委托(delegate),如下所示

import { android, on, launchEvent, ApplicationEventData } from '@nativescript/core/application';

// Typescript will require you to define those types
declare namespace androidx {
 export namespace appcompat {
  export namespace app {
   export const AppCompatDelegate: any;
  }
 }
}

if (android) {
 on(launchEvent, (args: ApplicationEventData) => {
  androidx.appcompat.app.AppCompatDelegate.setDefaultNightMode(androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO)
 });
}

关于angular - Nativescript Angular Android 应用程序强制灯光模式不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62064667/

相关文章:

javascript - 子路由在延迟加载中不起作用

javascript - 如何在 Angular 2 的 http post 请求中发送表单数据?

angular - 我是否需要完成一个 Subject 才能被垃圾收集?

javascript - ListView 和高度

python - 编写一次,到处测试 - Selenium 和 Python 在桌面和移动设备上的单元测试

Angular CLI 11 版本无法在 Internet Explorer 11 中运行

javascript - NativeScript 识别页面是否完全呈现

ios - 将 View 添加到 NativeScript ActionBar 会破坏导航

python - 导入模块时的错误处理

c++ - 英特尔 GPU、VBO 问题和 SFML