HarmonyOS Popup气泡支持边框问题?

需求场景:CoStudy app 中很多处引导及功能需要以气泡的方式展示

当前困难影响:目前HarmonyOS原生的popup 其他功能都可配置,但是没有找到描边的属性

阅读 553
1 个回答

Popup目前是不支持边框的,目前只能用阴影或者在没有箭头的情况下,用自定义气泡,给自定的row设置边框

// xxx.ets
@Entry
@Component
struct PopupExample {
  @State customPopup: boolean = false
  @State handlePopup: boolean = false
  build() {
    Column({ space: 100 }) {
      Button("popup")
        .margin({ top: 50 })
        .onClick(() => {
          this.customPopup = !this.customPopup
        })
        .bindPopup(this.customPopup, {
          message: "this is a popup",
          arrowHeight: 20, // 设置气泡箭头高度
          arrowWidth: 20, // 设置气泡箭头宽度
          radius: 20, // 设置气泡的圆角
          shadow: { radius: 5, color: Color.Blue }, // 设置气泡的阴影
          backgroundBlurStyle: BlurStyle.NONE,
        })

      Button('CustomPopupOptions')
        .onClick(() => {
          this.customPopup = !this.customPopup
        })
        .bindPopup(this.customPopup, {
          builder: this.popupBuilder,
          placement: Placement.Top,
          showInSubWindow: false,
          onStateChange: (e) => {
            if (!e.isVisible) {
              this.customPopup = false
            }
          },
          // 设置弹窗显示动效与退出动效为缩放动效
        })
        .position({ x: 80, y: 300 })
    }.width('100%')
  }

  @Builder
  popupBuilder() {
    Row() {
      Text('Custom Popup with transitionEffect').fontSize(10)
    }
    .height(50)
    .padding(5)
    .borderRadius(20)
    .borderStyle(BorderStyle.Solid)
    .borderWidth(3)
    .borderColor(Color.Blue)
  }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进