HarmonyOS 粘贴控件设置透明颜色显示黑色?

PasteButton({icon:null, text:PasteDescription.PASTE, buttonType:ButtonType.Capsule})

.backgroundColor(Color.Transparent)

设置透明背景颜色,显示黑色,效果参见截图

阅读 552
1 个回答

出于安全考虑,现在不支持设置透明。

如果之前是透明的设置,系统会强制设置成非透明的,需要重新适配背景色,透明度不低于10%

@Entry
@Component
struct index2 {
  build() {
    Column() {
      SaveButton({ icon: SaveIconStyle.FULL_FILLED })
        .iconColor(Color.Red)
        .backgroundColor(Color.Transparent)//不写是蓝色背景,写上是黑色背景。
        .backgroundColor('#33fffefe')
          //todo 设置按钮背景色不透明度 10%

        .iconSize(120)
        .width(200)
        .height(200)
    }
    .width('100%')
    .height('100%')
    .justifyContent(FlexAlign.Center)
    .backgroundColor(Color.Blue) //加背景后验证上面设置的SaveButton背景非透明
  }
}