子窗口无法避开系统导航条区域?

阅读 708
1 个回答

子窗口没有避开安全区域属于当前规格,由于悬浮子窗口的拖拽事件可能会把子窗口移动到任意位置,所以子窗口无法设置安全区域的规避规避系统导航条方式,在子窗口页面的根页面中进行规避:

import { windowStage_ } from '../entryability/EntryAbility'
import { window } from '@kit.ArkUI';

@Entry({ routeName: "SubWindowPage" })
@Component
struct SubWindowPage {
  @State message: string = 'Hello World';
  @State heightOfArea: number = 0
  aboutToAppear(): void {
    let mainWindow = (windowStage_ as window.WindowStage).getMainWindowSync()
    this.heightOfArea = mainWindow.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR).bottomRect.height;
    console.log(this.heightOfArea.toString())
  }

  build() {
    Column() {
      Text(this.message)
        .fontSize(50)
        .backgroundColor(Color.Green)
        .fontWeight(FontWeight.Bold)
    }
    .width('100%')
    .height('100%')
    .justifyContent(FlexAlign.End)
    .padding({
      bottom: px2vp(this.heightOfArea)
    })
  }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进