HarmonyOS promptAction.showActionMenu弹窗可否调整位置

HarmonyOS
2024-12-18 17:29:01
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
fox280

promptAction.showActionMenu弹窗是出现在底部,使用opencustomdialog,可以通过alignment或者offset来调整弹窗的位置。

import promptAction from '@ohos.promptAction'

let customDialogId: number = 0

@Builder
function customDialogBuilder() {
  Column() {
    Text('Custom dialog Message').fontSize(10)
    Column() {
      Button('确认').backgroundColor(Color.Transparent).fontColor('#666666').onClick(() => {
        promptAction.closeCustomDialog(customDialogId)
      })
      Blank().width(50)
      Button('取消').backgroundColor(Color.Transparent).fontColor('#000000').onClick(() => {
        promptAction.closeCustomDialog(customDialogId)
      })
    }
  }.height(200).padding(5)
}

@Entry
@Component
struct Index {
  @State message: string = 'Hello World'

  build() {
    Row() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
          .onClick(() => {
            promptAction.openCustomDialog({
              builder: customDialogBuilder.bind(this),
              alignment: DialogAlignment.Center
              // offset:{dx:0,dy:-260} //可以通过这个属性来设置位置
            }).then((dialogId: number) => {
              customDialogId = dialogId
            })
          })
      }
      .width('100%')
    }
    .height('100%')
  }
}
分享
微博
QQ
微信
回复
2024-12-18 19:18:52
相关问题
promptAction.openCustomDialog 全局弹窗
928浏览 • 1回复 待解决
鸿蒙如何调整组件位置
7879浏览 • 1回复 待解决
HarmonyOS怎么调整Radio的选项框的位置
600浏览 • 1回复 待解决
HarmonyOS tabs中的tabbar整体位置调整
264浏览 • 1回复 待解决
Scroll的子组件的展示位置如何调整
2843浏览 • 1回复 待解决
promptAction.openCustomDialog 自定义弹窗
608浏览 • 1回复 待解决