HarmonyOS 自定义Dialog高度问题

private chooseProjectsController: CustomDialogController = new CustomDialogController({
  builder: RecordFlowProjectsDialog({
    //...
  }),
  alignment: DialogAlignment.CenterEnd,
  autoCancel: true,
  customStyle: true
  // maskColor: $r('app.color.scaffold_fg_dark_1_alpha_50'),
})
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.

RecordFlowProjectsDialog是一个自定义空白dialog,高度设置的100%,发现dialog显示在状态栏下

HarmonyOS
2024-12-25 13:14:16
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
superinsect

示例如下:

@CustomDialog
struct CustomDialogExample {
  cancel?: () => void
  confirm?: () => void
  controller: CustomDialogController

  build() {
    Column() {
      Text('我是内容').fontSize(20).margin({ top: 10, bottom: 10 })
    }.height('100%')
  }
}

@Entry
@Component
struct CustomDialogUser {
  dialogController: CustomDialogController = new CustomDialogController({
    builder: CustomDialogExample({
      cancel: ()=> { this.onCancel() },
      confirm: ()=> { this.onAccept() },
    }),
    alignment: DialogAlignment.Center,
    autoCancel: true,
    customStyle: true
  })

  onCancel() {
    console.info('Callback when the first button is clicked')
  }

  onAccept() {
    console.info('Callback when the second button is clicked')
  }

  build() {
    Column() {
      Button('click me')
        .onClick(() => {
          this.dialogController.open()
        })
    }.width('100%').height('100%')
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
分享
微博
QQ
微信
回复
2024-12-25 14:22:59
相关问题
HarmonyOS 自定义Dialog显示问题
1257浏览 • 1回复 待解决
HarmonyOS 自定义dialog相关问题
742浏览 • 1回复 待解决
HarmonyOS 自定义全局dialog
696浏览 • 1回复 待解决
HarmonyOS 自定义Dialog宽度
846浏览 • 1回复 待解决
HarmonyOS 自定义全屏dialog
889浏览 • 1回复 待解决
HarmonyOS 自定义Dialog背景色透明问题
1902浏览 • 1回复 待解决
HarmonyOS 如何封装自定义Dialog
819浏览 • 1回复 待解决
HarmonyOS 自定义dialog open无效
957浏览 • 1回复 待解决
HarmonyOS 用CustomDialog自定义Dialog
1132浏览 • 1回复 待解决
HarmonyOS 自定义dialog封装后全局调用
765浏览 • 1回复 待解决
HarmonyOS 自定义组件如何获取高度
1032浏览 • 1回复 待解决
鸿蒙怎么实现自定义布局的Dialog
10078浏览 • 2回复 已解决
HarmonyOS 如何在class中显示自定义dialog
758浏览 • 1回复 待解决