HarmonyOS Popup宽度问题?

bindPopup中不设置width会发现弹出的pop屏幕左右是有边距的,而内容区又是屏幕的宽度,导致内容显示不全。如果设置100%,可以填充屏幕宽度。我想知道在不设置width时系统默认的左右边距是多少?

阅读 469
1 个回答

目前没有办法设置pop自己的位置,只能相对触发组件的位置,可以参考下面demo:

@Entry
@Component
struct PopupExample {
  @State handlePopup: boolean = false
  @State a:number|undefined = 1
  build() {
    Flex({ direction: FlexDirection.Column }) {
      // PopupOptions 类型设置弹框内容
      Button('PopupOptions')
        .onClick(() => {
          this.handlePopup = !this.handlePopup
        })
        .bindPopup(this.handlePopup, {
          message: 'This is a popup with PopupOptions',
          width:500,
          placementOnTop: true,
          showInSubWindow:true,
        }).position({
        left:'32%'
      })
    }.width('100%').padding({ top: 5 })
  }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进