HarmonyOS promptAction.showDialog的title和message居中显示

怎么设置 title 和 message 居中显示

HarmonyOS
2024-12-24 16:18:23
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zbw_apple

若想居中显示,可采用以下方式:

import promptAction from '@ohos.promptAction'
let customDialogId: number = 0
@Builder
function customDialogBuilder() {
  Column() {
    Text('提示信息').fontSize(30)
    Text('提示内容').fontSize(15)
    Row() {
      Button("确认").onClick(() => {
        promptAction.closeCustomDialog(customDialogId)
      })
    }
  }.height(200).padding(10)
}

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

  build() {
    Row() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
          .onClick(() => {
            promptAction.openCustomDialog({
              builder: customDialogBuilder.bind(this)
            }).then((dialogId: number) => {
              customDialogId = dialogId
            })
          })
      }
      .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.
分享
微博
QQ
微信
回复
2024-12-24 17:16:01
相关问题
HarmonyOS AlertDialogtitle居中显示
589浏览 • 1回复 待解决
HarmonyOS Navigation中title怎么居中显示
847浏览 • 1回复 待解决
HarmonyOS NavDestinationtitle怎么居中
827浏览 • 1回复 待解决
HarmonyOS RichEditor 内容不居中显示
659浏览 • 1回复 待解决
HarmonyOS 组件剩余区域居中显示
573浏览 • 1回复 待解决