【发布时间】:2020-11-30 04:18:57
【问题描述】:
如何隐藏特定活动的状态栏?
我发现了这个类似的问题,但没有一个答案对我有用。
该应用程序每次都崩溃并显示错误无法读取属性getWindow 在genymotion andriod VM 上运行我的应用程序时。以下是简短的错误屏幕截图
下面是我的 home.component.ts 代码
import { Component, OnInit } from "@angular/core";
import {Page} from "ui/page";
import * as app from "tns-core-modules/application";
@Component({
selector: "Home",
moduleId: module.id,
templateUrl: "./home.component.html",
styleUrls: ["./home.component.scss"]
})
export class HomeComponent implements OnInit {
constructor(page: Page) {
page.actionBarHidden = true;
this.statusBar('hide');
}
ngOnInit(): void {
// Init your component properties here.
}
statusBar(action: string){
var activity = app.android.startActivity;
//activity.runOnUiThread(function(){
var win = activity.getWindow();
if(action === 'hide'){
win.addFlags(app.android.nativeApp.view.WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else if(action === 'show'){
win.clearFlags(app.android.nativeApp.view.WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
}
请帮助我。谢谢。
【问题讨论】:
标签: nativescript angular2-nativescript