解决措施可通过通用属性linearGradient来实现组件边缘的颜色渐变效果。示例代码// xxx.ets @Entry @Component struct Index { build() { Row() { Column() { Column({ space: 5 }) { Text('linearGradient').fontSize(12).width('90%').fontColor(0xCCCCCC) Row() { Text('This is gradient color.') .textAlign(TextAlign.Center) .width('96%') .height('80%') .borderRadius(30) .linearGradient({ direction: GradientDirection.Left, // 渐变方向 repeating: true, // 渐变颜色是否重复 colors: [[0xDCDCDC, 0.0], [0xFFFFFF, 1.0]] // 数组末尾元素占比小于1时满足重复着色效果 }) } .width('90%') .height(60) .borderRadius(30) .linearGradient({ angle: 90, colors: [[0x87CEEB, 0.0], [0x2E8B57, 1.0]] }) .justifyContent(FlexAlign.Center) } } .width('100%') } .height('100%') } }
解决措施
可通过通用属性linearGradient来实现组件边缘的颜色渐变效果。
示例代码