在HarmonyOS NEXT开发中如何实现将背景颜色设置透明度?如何实现将背景颜色设置透明度,例如
Text(item.tag).backgroundColor(Color.Gray).fontColor(Color.White)我只想让这个text的背景色具有透明度的效果目前我使用了 .opacity(0.8)来设置,是影响到文字颜色的透明度了
Column() {
Text("曲阜市三孔旅游区")
.fontSize("46lpx")
.fontColor(Color.White)
.margin({ bottom: "20lpx" })
Row() {
Text("5A")
.fontColor(Color.White)
.backgroundColor("#DC4237")
.padding({
top: "5lpx",
bottom: "5lpx",
left: "14lpx",
right: "14lpx"
})
.fontSize("29lpx")
.borderRadius({
topRight: "23lpx",
bottomLeft: "23lpx"
})
Text("不负春光踏青而行")
.fontColor(Color.White)
.fontSize("29lpx")
.margin({ left: 10 })
}
}
.width("100%")
.padding({
top: "10lpx"
})
.height("150lpx")
.backgroundColor("#333333")
.borderRadius({
bottomLeft: "58lpx",
bottomRight: "58lpx"
})
.opacity(0.5)
}
背景色的透明度不用opacity来设置,可以直接使用rgba来进行设置。