2

我在 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 上运行。

本机脚本版本:6.5.0 角度版本:8

4

1 回答 1

2

对于 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)
 });
}
于 2020-05-28T13:06:17.553 回答