HarmonyOS Tabs如何把其扩展安全区域到Bottom

Tabs,位置是END,如何把其扩展安全区域到Bottom

HarmonyOS
2024-12-24 18:18:38
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
FengTianYa

tabs可以扩展安全区域到Bottom,参考示例如下:

@Entry
@Component
struct TabsExample {
  @State fontColor: string = '#182431'
  @State selectedFontColor: string = '#007DFF'
  @State currentIndex: number = 0
  private controller: TabsController = new TabsController()

  @Builder tabBuilder(index: number, name: string) {
    Column() {
      Text(name)
        .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor)
        .fontSize(16)
        .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%')
  }

  build() {
    Column() {
      Tabs({ barPosition: BarPosition.End, index: this.currentIndex, controller: this.controller }) {
        TabContent() {
          Column().width('100%').height('100%').backgroundColor('#00CB87')
        }.tabBar(this.tabBuilder(0, 'green'))

        TabContent() {
          Column().width('100%').height('100%').backgroundColor('#007DFF')
        }.tabBar(this.tabBuilder(1, 'blue'))

        TabContent() {
          Column().width('100%').height('100%').backgroundColor('#FFBF00')
        }.tabBar(this.tabBuilder(2, 'yellow'))

        TabContent() {
          Column().width('100%').height('100%').backgroundColor('#E67C92')
        }.tabBar(this.tabBuilder(3, 'pink'))
      }
      .expandSafeArea([SafeAreaType.SYSTEM],[SafeAreaEdge.BOTTOM])
      .vertical(false)
      .barMode(BarMode.Fixed)
      .onChange((index: number) => {
        this.currentIndex = index
      })
      .backgroundColor('#ffe0a8f5')
    }.width('100%').height('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.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
分享
微博
QQ
微信
回复
2024-12-24 19:51:55


相关问题
HarmonyOS 视频组件无法扩展安全区域
1091浏览 • 1回复 待解决
HarmonyOS 安全区域出错
803浏览 • 1回复 待解决
HarmonyOS 安全区域失效
767浏览 • 1回复 待解决
HarmonyOS 安全区域问题
996浏览 • 1回复 待解决
HarmonyOS WebView安全区域问题
616浏览 • 1回复 待解决
HarmonyOS scroll安全区域问题
860浏览 • 1回复 待解决
HarmonyOS 设置安全区域不生效
853浏览 • 1回复 待解决
HarmonyOS 如何获取手机安全区域高度
806浏览 • 1回复 待解决
HarmonyOS 页面底部流出安全区域
877浏览 • 1回复 待解决
关于屏幕安全区域的问题咨询
1093浏览 • 1回复 待解决