HarmonyOS Tab 如何改变下标的颜色?

Tab 如何改变下标的颜色?默认是蓝色。怎么修改成其他颜色

阅读 507
1 个回答

尝试如下方案

Tabs({ barPosition: BarPosition.Start, controller: this.controller }) {
  TabContent() {
    Column().width('100%').height('100%').backgroundColor('#00CB87')
  }.tabBar(this.TabBuilder(0, 'green'))
}

@Builder TabBuilder(index: number, name: string) {
  Column() {
    Text(name)
      .fontSize(16)
      .fontColor('#00CB87')
      .fontWeight(this.currentIndex === index ? 500 : 400)
      .lineHeight(22)
      .margin({ top: 17, bottom: 7 })
    Divider()
      .strokeWidth(2)
      .color('#007DFF')
      .opacity(this.currentIndex === index ? 1 : 0)
  }.width('100%')
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进