HarmonyOS 鸿蒙Next中ImageSpan背景色问题

HarmonyOS 鸿蒙Next中ImageSpan背景色问题 我的目的是修改 ImageSpan 图片的颜色,发现 colorBlend 方法可以修改,但是修改之后会出现白色的背景,尝试使用 backgroundColor 改成和 page 相同的颜色,发现色值出现了偏差。测试发现 ImageSpan 的 backgroundColor 和 Image 不同,怎么把 ImageSpan 的背景色去掉?

DevEco Studio NEXT Beta1 Build #DS-233.14475.28.36.503800
Build Version: 5.0.3.800, built on September 4, 2024
Runtime version: 17.0.10+1-b1087.17 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 14.5
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 10
Metal Rendering is ON
Registry: idea.plugins.compatible.build=IC-233.14475.28
Non-Bundled Plugins: com.huawei.deveco.intelligent-assistant (0.406.7)


更多关于HarmonyOS 鸿蒙Next中ImageSpan背景色问题的实战教程也可以访问 https://www.itying.com/category-93-b0.html

1 回复

更多关于HarmonyOS 鸿蒙Next中ImageSpan背景色问题的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


对线条进行着色只有Image的ColorFilter可以做到,下面这个demo可以实现,可以以此为基础修改:

@Component
@Entry
struct Index {

  string = '这个是一段测试内容'

  build() {
    Column({
      wrap: FlexWrap.Wrap,
      alignItems: ItemAlign.Center
    }){
      Flex({
        wrap: FlexWrap.Wrap,
        alignItems: ItemAlign.Center
      }){
        Text("专题")
          .backgroundColor("red")
          .padding(2)
          .fontSize(15)
          .padding(5)
          .borderRadius(4)
          .margin({right: 5})
        ForEach(this.string.split(''), (item:string,index)=>{
          Text(item)
            .fontSize(30)
        })
        Row(){
          ForEach('测试标题'.split(''), (item:string,index)=>{
            Text(item)
              .fontSize(15)
          })
        }
          .border({width: 1})
        ForEach(this.string.split(''), (item:string,index)=>{
          Text(item)
            .fontSize(30)
        })
        Image($r('app.media.dui_page_arrow'))
          .width(30)
          .height(30)
          .fillColor('#FF0000')
          // .colorBlend('red')
      }
        .width(300)
        .backgroundColor('#33333333')
    }
      .width('100%')
      .alignItems(HorizontalAlign.Center)
  }
}
回到顶部