HarmonyOS 鸿蒙Next中Navigation默认自带expandSafeArea? 另外NavDestination设置systemTransition(NavigationSystemTransitionType.SLIDE_BOTTOM)后pop动画会卡顿!
HarmonyOS 鸿蒙Next中Navigation默认自带expandSafeArea? 另外NavDestination设置systemTransition(NavigationSystemTransitionType.SLIDE_BOTTOM)后pop动画会卡顿!
[@Entry](/user/Entry)
[@Component](/user/Component)
struct NavigationPage {
pathStack: NavPathStack = new NavPathStack();
build() {
Navigation(this.pathStack) {
Button('goto PageOne')
.onClick(()=>{
this.pathStack.pushPathByName('pageOne',undefined)
}).margin({top:50})
}
.height('100%')
.width('100%')
.backgroundColor(Color.Orange)
.hideToolBar(true)
}
}
问题一:没有设置window.setWindowLayoutFullScreen(true),Navigation也没设置expandSafeArea,如图Navigation的背景颜色就自己延伸到状态栏和导航条了,Navigation是否是默认自带expandSafeArea效果?
[@Component](/user/Component)
struct pageOne{
build() {
NavDestination() {
}.title('pageOne')
.backgroundColor(Color.Yellow)
.systemTransition(NavigationSystemTransitionType.SLIDE_BOTTOM)
}
}
NavDestination设置系统转场动画SLIDE_BOTTOM,(如图)点击返回这个pageOne会移动到距离底部状态栏目加导航条的高度后卡住一段时间然后就瞬间消失,这个是否是由于Navigation默认自带expandSafeArea效果导致的bug?
```更多关于HarmonyOS 鸿蒙Next中Navigation默认自带expandSafeArea? 另外NavDestination设置systemTransition(NavigationSystemTransitionType.SLIDE_BOTTOM)后pop动画会卡顿!的实战教程也可以访问 https://www.itying.com/category-93-b0.html
@Entry
@Component
struct NavigationPage {
pathStack: NavPathStack = new NavPathStack();
build() {
Navigation(this.pathStack) {
Button('goto PageOne')
.onClick(()=>{
this.pathStack.pushPathByName('pageOne',undefined)
}).margin({top:50})
}
.height('100%')
.width('100%')
.backgroundColor(Color.Orange)
.hideToolBar(true)
.expandSafeArea([],[])
}
}
Navigation和NavDestination加上expandSafeArea([],[])
,SLIDE_BOTTOM转场动画就不卡顿了,或者设置window.setWindowLayoutFullScreen(true)
动画也不卡顿了
更多关于HarmonyOS 鸿蒙Next中Navigation默认自带expandSafeArea? 另外NavDestination设置systemTransition(NavigationSystemTransitionType.SLIDE_BOTTOM)后pop动画会卡顿!的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
在HarmonyOS Next中,Navigation组件默认开启了expandSafeArea特性。关于NavDestination设置systemTransition(NavigationSystemTransitionType.SLIDE_BOTTOM)后pop动画卡顿问题,这是已知性能问题,与系统过渡动画的渲染机制有关。当前版本中Bottom类型过渡动画在pop操作时存在帧率下降现象。
关于Navigation组件在HarmonyOS Next中的表现:
-
Navigation组件确实默认具有expandSafeArea效果,即使未显式设置window.setWindowLayoutFullScreen(true)或expandSafeArea属性,其内容也会自动延伸到状态栏和导航条区域。这是设计上的默认行为。
-
关于NavDestination设置SLIDE_BOTTOM转场动画后pop卡顿的问题:
- 这个现象确实与默认的expandSafeArea行为有关
- 当使用底部滑动动画时,系统需要处理安全区域的过渡,可能导致动画在接近底部时出现卡顿
- 目前这是一个已知的框架层问题,建议暂时避免同时使用expandSafeArea和SLIDE_BOTTOM动画组合
可以尝试以下临时解决方案:
- 显式设置expandSafeArea(false)
- 使用自定义动画替代系统预设的SLIDE_BOTTOM
- 等待后续版本修复此问题