Nativescript Angular安卓应用强制轻模式无法使用

问题描述 投票:0回答:1

我在API 29中使用angular构建的nativescript安卓应用无法从values-v29文件夹中获取style.xml设置。

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

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

Theme.setMode(Theme.Light);

我漏了什么?在IOS上通过修改Info.plist文件就可以了。

原生脚本版本:6.5.0 角度版本:8。

angular nativescript cross-platform nativescript-angular angular-nativescript
1个回答
1
投票

对于Android来说,你可能需要实现一个应用程序委托,在你的 main.ts 如下

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)
 });
}
© www.soinside.com 2019 - 2024. All rights reserved.