HarmonyOS Tabs TabBuild高度被系统限定

HarmonyOS
2024-12-18 17:16:08
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
shlp
@Entry
@Component
struct TabsKeyPage {
  @State keys: Array<string> = []

  aboutToAppear(): void {
    for (let i = 0; i < 4; i++) {
      this.keys.push(i.toString())
    }
    console.log("tag", JSON.stringify(this.keys));
  }

  @Builder
  tabBuilder(index: number, name: string) {
    Column() {
      Text(name)
        .fontSize(16)
        .lineHeight(22)
        .margin({ top: 17, bottom: 7 })
      Divider()
        .strokeWidth(2)
        .color('#007DFF')
    }
    .width('100%')

    // .height("200")
  }

  build() {
    RelativeContainer() {
      Tabs() {
        ForEach(this.keys, (item: string, index: number) => {
          TabContent() {
            Text("AAAAAAAAAAAAA").width("100%").fontColor(Color.Green).fontSize(30).height("100%")
          }
          .tabBar(this.tabBuilder(0, 'green'))
        })
      }
      .barHeight(200)
      // .height('100%')
      .width('100%')
      .backgroundColor(Color.White)
    }
    .height('100%')
    .width('100%')
  }
}
  • 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.

设置barHeight的值可改变高度,但要注意其他注释的height,如果设置了,该值无效。

关于barHeight的说明规则请参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-container-tabs-V5

还有一些其他实现方法也可参考:https://developer.huawei.com/consumer/cn/forum/topic/0203142190027243403?fid=0101587866109860105

分享
微博
QQ
微信
回复
2024-12-18 19:32:14
相关问题
HarmonyOS Tabs默认高度问题
974浏览 • 1回复 待解决
系统Tabs组件用法有哪些?
1352浏览 • 1回复 待解决
HarmonyOS 如何获取系统状态栏高度
1627浏览 • 1回复 待解决
如何禁止Tabs系统切换逻辑
2756浏览 • 0回复 待解决
HarmonyOS如何获取系统软键盘的高度
1391浏览 • 1回复 待解决
HarmonyOS Tabs组件嵌套Tabs组件问题
1777浏览 • 1回复 待解决
HarmonyOS Tabs
443浏览 • 1回复 待解决
HarmonyOS Tabs组件的Tabs如何左对齐?
1245浏览 • 1回复 待解决