HarmonyOS 自定义弹窗设置背景色与实际效果不对,并且内部某个节点设置背景色不生效

我使用的是promptAction.openCustomDialog 自定义弹窗,需要把弹窗自己本身附带的背景去掉,同时在自定义弹窗内部我设置了一个节点的背景,发现无法生效,具体代码及效果详见截图

HarmonyOS 自定义弹窗设置背景色与实际效果不对,并且内部某个节点设置背景色不生效 -鸿蒙开发者社区

HarmonyOS 自定义弹窗设置背景色与实际效果不对,并且内部某个节点设置背景色不生效 -鸿蒙开发者社区

HarmonyOS
2025-01-09 15:35:58
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
fox280

请参考demo

import promptAction from '@ohos.promptAction'
let customDialogId: number = 0
@Builder
function customDialogBuilder() {
  Column() {
    Column(){

      Image($r('app.media.startIcon')).width(20).height(20)
    }
    .width(100).height(100)
    .border({
      width: { left: 2, right: 2, top: 2, bottom: 2 },
      color: Color.Black
    })
    .backgroundColor('#0000FF')

    Row() {
      Button('确认').onClick(() => {
        promptAction.closeCustomDialog(customDialogId)
      })
      Blank().width(50)
      Button('取消').onClick(() => {
        promptAction.closeCustomDialog(customDialogId)
      })
    }
  }.width('100%').height(200).padding(5).backgroundColor("#808080")
}

@Entry
@Component
struct Index {
  @State message: string = '点我'

  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.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
分享
微博
QQ
微信
回复
2025-01-09 17:45:45
相关问题
HarmonyOS 如何设置渐变背景色
2227浏览 • 1回复 待解决
HarmonyOS 弹窗自带背景色
492浏览 • 1回复 待解决
如何设置WebView的背景色
1611浏览 • 1回复 待解决
如何设置窗口的背景色
2580浏览 • 1回复 待解决
HarmonyOS 自定义Dialog背景色透明问题
1901浏览 • 1回复 待解决
Button组件如何设置渐变背景色
3722浏览 • 1回复 待解决
HarmonyOS 弹框背景色如何自定义图片
631浏览 • 1回复 待解决
HarmonyOS Select组件的背景色如何设置
577浏览 • 1回复 待解决
使用js引擎 设置dom背景色无效
1351浏览 • 0回复 待解决
AlertDialog没有找到设置背景色API
1227浏览 • 1回复 待解决
HarmonyOS 关于开屏背景色
589浏览 • 1回复 待解决
HarmonyOS List组如何将背景色设置透明
524浏览 • 1回复 待解决
如何设置背景色的饱和度和亮度?
928浏览 • 1回复 待解决
TextInput按压态背景色如何修改
3232浏览 • 1回复 待解决