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