【问题标题】:Nativescript Angular Android App forced light mode not workingNativescript Angular Android App强制光照模式不起作用
【发布时间】:2020-09-15 18:23:30
【问题描述】:

我在 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

【问题讨论】:

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


    【解决方案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)
     });
    }
    

    【讨论】:

    • 我确实在 main.ts 和 main.tns.ts 文件上尝试过这个,没有任何区别。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-31
    • 1970-01-01
    • 2012-06-15
    相关资源
    最近更新 更多