【发布时间】:2019-05-13 00:30:24
【问题描述】:
我正在构建一个 ionic 4 应用程序,在 android 上运行时,状态栏是黑色的,我想更改它,但我无法弄清楚。
我尝试更改 config.xml 中的首选项,OverlayWebView true 和 false,并尝试只使用 this.statusBar.backroundcolor... 的东西。没有任何效果。 状态栏插件已安装。
Config.xml:
<preference name="ScrollEnabled" value="false" />
<preference name="android-minSdkVersion" value="19" />
<preference name="BackupWebStorage" value="none" />
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="FadeSplashScreenDuration" value="300" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="3000" />
<preference name="StatusBarBackgroundColor" value="#ffffff" />
<preference name="StatusBarOverlaysWebView" value="true" />
App.component.ts
import { StatusBar } from '@ionic-native/status-bar/ngx';
@Component({
selector: 'app-root',
templateUrl: 'app.component.html'
})
export class AppComponent {
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar
) {
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.splashScreen.hide();
this.statusBar.overlaysWebView(true);
this.statusBar.backgroundColorByHexString('#ffffff');
});
}
}
我想更改显示时间、电池电量等状态栏的颜色,但无论我做什么,它都保持黑色。
【问题讨论】:
-
删除状态栏的所有行。只要把这个 this.statusBar.backgroundColorByHexString('#ffffff'); config.xml 也不需要任何更改
-
很抱歉,这不起作用。
-
我使用上面对我有用的行遇到了同样的问题。
标签: android ionic-framework ionic4