【发布时间】:2020-04-15 06:22:49
【问题描述】:
我制作了一个带有默认主题 (Ionic 5) 的空白启动应用程序。
对于 Android,这就是它的外观。这看起来很奇怪,因为我希望将原色的较暗版本用作状态栏的颜色。
状态栏为黑色。将状态栏的颜色设置为其他颜色的正确方法是什么?
我尝试了以下方法:
- 状态栏
this.statusBar.backgroundColorByHexString('#ffffff'); - 首选项中的状态栏颜色
<preference name="StatusBarBackgroundColor" value="#457492" />
但这些都不起作用。目前,我已经通过 Android 项目的 MainActivity 来执行此操作。
getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.status_bar_color));
app.component.ts
export class AppComponent {
navigate: any;
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.backgroundColorByHexString('#ff371d');
this.sideMenu();
});
}
}
【问题讨论】:
-
第一个是正确的,但只需删除 this.statusbar.deafultStyle() ,因为它可能与此方法发生冲突。
-
还是不行。
-
在您的问题中添加您的 app.compoent.ys。
-
this.statusBar.backgroundColorByName("red");试试这个,虽然 backgrounscolorbyhexstring 应该可以正常工作,但让我们看看错误在哪里,对于 statusbar.defaultstyle,它的状态栏中图标或文本的颜色为黑色或白色
-
尝试:
this.statusBar.styleDefault(); this.statusBar.styleBlackTranslucent();侧边initializeApp()
标签: android ionic-framework ionic-native ionic5