HarmonyOS 鸿蒙Next状态栏
HarmonyOS 鸿蒙Next状态栏 沉浸状态栏和导航栏怎么弄啊
在EntryAbility.ets
中的onWindowStageCreate()
中加入以下代码:
let windowClass: window.Window = null;
windowStage.getMainWindow((err, data) => { //获取主窗口
if (err.code) {
console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
return;
}
windowClass = data;
console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
windowClass.setWindowLayoutFullScreen(true); //设为全屏
//显示状态栏, 'navigation' 如需显示导航栏,加入到下面数组中
windowClass.setWindowSystemBarEnable(['status'], (err) => {
if (err.code) {
console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting the system bar to be visible.');
});
})
更多关于HarmonyOS 鸿蒙Next状态栏的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
状态栏和导航栏都显示并沉浸怎么弄呢,
状态栏和导航栏都显示并沉浸怎么弄呢,
let SystemBarProperties = { statusBarColor: ‘#00000000’, navigationBarColor: ‘#00000000’, } //设置窗口内导航栏、状态栏的属性,使用callback异步回调。 windowClass.setWindowSystemBarProperties(SystemBarProperties, (err) => { if (err) { console.error('Failed to set the system bar properties. Cause: ’ + JSON.stringify(err)) return } console.info(‘Succeeded in setting the system bar properties.’) }) let area = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM) let topMargin = area.topRect.height; let bottomMargin = area.bottomRect.height; // 保存高度信息: 后续布局时将状态栏及导航栏位置padding掉,
拿到的bottomMargin一直是0,
基础信息
- 姓名:张三
- 职位:软件工程师
- 技能:
- Java
- Python
- C++
- 联系方式:
- 邮箱:zhangsan@example.com
- 手机:12345678901
HarmonyOS 鸿蒙Next的状态栏设计延续了简洁、高效的理念,支持实时显示系统状态、通知和快捷操作。用户可以通过状态栏快速访问Wi-Fi、蓝牙、电池状态等信息,并接收应用通知。鸿蒙Next还引入了智能场景识别功能,根据用户当前使用场景动态调整状态栏显示内容,提升交互体验。此外,状态栏支持自定义布局,用户可根据个人需求调整显示项,进一步优化使用效率。