HarmonyOS button设置相同颜色值的背景色和渐变色,为什么效果不一致?

demo代码:

@Entry
@Component
struct Index231231 {
  build() {
    Row() {
      Button( "同意协议并付款" , { type: ButtonType.Normal })
        .width('100%')
        .height(48)
        .fontSize(16)
        .fontColor("#FFFFFF")
        .borderRadius(12)
        .fontWeight(500)
        .linearGradient({
          direction: GradientDirection.Left,
          colors: [[0x0A1B1B1B , 0.0],
            [ 0x0A1B1B1B , 1.0]]
        })
    }
    .margin({ top: 20, left: 20, right: 20 })
  }
}
阅读 663
1 个回答

button默认有背景色,然后设置的渐变色是带透明度的,所以透过去看过去是自带的背景色,可将backgroundColor设为透明。