HarmonyOS 同一个颜色值,为啥backgroundColor和linearGradient显示的不一样?

demo代码:

import { promptAction } from '@kit.ArkUI';
@Entry
@Component
struct Index23123 {
  build() {
    Column(){
      Row()
        .height(100)
        .width('100%')
        .backgroundColor('0x0A1B1B1B')
      Row()
        .height(100)
        .width('100%')
        .linearGradient({
          direction: GradientDirection.Left,
          colors: [[0x0A1B1B1B, 0.0],
            [0x0A1B1B1B, 1.0]]
        })
    }
  }
}
阅读 534
1 个回答

backgroundColor使用HEX格式的颜色不需要加引号,请将引号去掉:

Row()
  .height(100)
  .width('100%')
  .backgroundColor(0x0A1B1B1B)
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进