【发布时间】:2020-11-09 18:27:51
【问题描述】:
我正在尝试将我在 Android 上的 uiVisibility 设置为像这样的粘性和沉浸式:
const View = android.view.View;
const window = app.android.startActivity.getWindow();
const decorView = window.getDecorView();
decorView.setSystemUiVisibility(
// tslint:disable-next-line: no-bitwise
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_LOW_PROFILE |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
但是每次我构建时,我都会在终端中收到一条错误消息,类似这样的
ERROR in src/app/common/services/ui.service.ts:25:18 - error TS2339: Property 'SYSTEM_UI_FLAG_IMMERSIVE_STICKY' does not exist on type 'typeof View'.
25 View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
现在,我设法通过在我的 /node_modules/@nativescript/types-android/lib/android/android-platform-17.d.ts 文件中添加一个常量值来解决这个问题,之后我没有收到任何错误。尽管这可行,但我不喜欢在 node_modules 中干预我的文件,而且我确定我不打算这样做,而且每次我 tns clean && npm install 时,我都会再次收到错误。问题是,我不明白为什么要引用 platform-17 文件,因为我的目标 sdk 版本是 23,所以引用这个文件没有意义。
我在我的项目中使用 Nativesript 7 和 Angular 10,我的 references.d.ts 文件看起来像这样:
/// <reference path="./node_modules/@nativescript/types/index.d.ts" />
/// <reference path="./node_modules/@nativescript/types/ios.d.ts" />
/// <reference path="./node_modules/@nativescript/types/android.d.ts" />
/// <reference path="./node_modules/@nativescript/core/global-types.d.ts" />
【问题讨论】:
标签: android typescript nativescript typescript-typings nativescript-angular