HarmonyOS ArkUI中TabContent组件,IndicatorStyle的marginTop属性不生效

官方api文档链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-container-tabcontent-V5#indicatorstyle10%E5%AF%B9%E8%B1%A1%E8%AF%B4%E6%98%8E

代码如下:

@Component
export struct TabsView {
  @State currentIndex: number = 0

  subTabBarGenerator(barName: string) {
    return SubTabBarStyle.of(barName)
      .labelStyle({
        font: {
          size: 18
        }
      })
      .padding(0)
      .indicator({
        borderRadius: 2.5,
        color: '#ff347aea',
        height: 2.5,
        marginTop: 20,
        width: 30,
      })
  }

  build() {
    Tabs({ index: this.currentIndex }) {
      TabContent() {
        NoneContentView()
      }
      .tabBar(this.subTabBarGenerator('动态'))
      .backgroundColor($r('app.color.color_FFFFFF'))

      TabContent() {
        // 作品列表
        WorkListView()
      }
      .tabBar(this.subTabBarGenerator('作品'))
      .backgroundColor("rgba(230, 230, 230, 0.80)")

      TabContent() {
        NoneContentView()
      }
      .tabBar(this.subTabBarGenerator('相册'))
      .backgroundColor($r('app.color.color_FFFFFF'))

    }
    .animationDuration(Constant.ANIMATION_DURATION)
    .backgroundColor($r('app.color.color_FFFFFF'))
    .barMode(BarMode.Fixed)
    .onChange((index: number) => {
      this.currentIndex = index;
    })
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
HarmonyOS
2025-01-09 15:26:40
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
superinsect
分享
微博
QQ
微信
回复
2025-01-09 19:06:37


相关问题
List组件initialIndex属性设置生效
2954浏览 • 1回复 待解决
textfield截断属性生效
3461浏览 • 1回复 待解决
通过WindowProperties设置属性生效
3009浏览 • 1回复 待解决
用数组变量控制组件属性生效
2329浏览 • 1回复 待解决
在嵌套组件Scroll生效
2806浏览 • 1回复 待解决
HarmonyOS Web组件borderRadius生效
1055浏览 • 1回复 待解决
容器组件onVisibleAreaChange生效
2767浏览 • 1回复 待解决
HarmonyOS 组件切换深色模式生效
1258浏览 • 1回复 待解决
HarmonyOS ArkWeb组件加载url生效
1031浏览 • 1回复 待解决
Web组件onKeyEvent键盘事件生效
2575浏览 • 1回复 待解决