chinese直男口爆体育生外卖, 99久久er热在这里只有精品99, 又色又爽又黄18禁美女裸身无遮挡, gogogo高清免费观看日本电视,私密按摩师高清版在线,人妻视频毛茸茸,91论坛 兴趣闲谈,欧美 亚洲 精品 8区,国产精品久久久久精品免费

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫(xiě)文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

鴻蒙ArkTS容器組件:TabContent

jf_46214456 ? 來(lái)源:jf_46214456 ? 作者:jf_46214456 ? 2024-07-15 15:04 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

TabContent

僅在Tabs中使用,對(duì)應(yīng)一個(gè)切換頁(yè)簽的內(nèi)容視圖。

說(shuō)明:
開(kāi)發(fā)前請(qǐng)熟悉鴻蒙開(kāi)發(fā)指導(dǎo)文檔 :[gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md]
該組件從API Version 7開(kāi)始支持。后續(xù)版本如有新增內(nèi)容,則采用上角標(biāo)單獨(dú)標(biāo)記該內(nèi)容的起始版本。

子組件

支持單個(gè)子組件。

說(shuō)明:

可內(nèi)置系統(tǒng)組件和自定義組件,支持渲染控制類型([if/else]、[ForEach]和[LazyForEach])。

接口

TabContent()

屬性

除支持[通用屬性]外,還支持以下屬性:

名稱參數(shù)類型描述
tabBarstring[Resource]
tabBar9+[SubTabBarStyle][BottomTabBarStyle]

說(shuō)明:

  • TabContent組件不支持設(shè)置通用寬度屬性,其寬度默認(rèn)撐滿Tabs父組件。
  • TabContent組件不支持設(shè)置通用高度屬性,其高度由Tabs父組件高度與TabBar組件高度決定。
  • vertical屬性為false值,交換上述2個(gè)限制。
  • TabContent組件不支持內(nèi)容過(guò)長(zhǎng)時(shí)頁(yè)面的滑動(dòng),如需頁(yè)面滑動(dòng),可嵌套List使用。

SubTabBarStyle9+

子頁(yè)簽樣式。

constructor

constructor(content: string | Resource)

SubTabBarStyle的構(gòu)造函數(shù)。

參數(shù):

參數(shù)名參數(shù)類型必填參數(shù)描述
contentstring[Resource]

of10+

static of(content: ResourceStr)

SubTabBarStyle的靜態(tài)構(gòu)造函數(shù)。

參數(shù):

參數(shù)名參數(shù)類型必填參數(shù)描述
content[ResourceStr]頁(yè)簽內(nèi)的文字內(nèi)容。

屬性

支持以下屬性:

名稱參數(shù)類型描述
indicator10+[IndicatorStyle]設(shè)置選中子頁(yè)簽的下劃線風(fēng)格。子頁(yè)簽的下劃線風(fēng)格僅在水平模式下有效。
selectedMode10+[SelectedMode]設(shè)置選中子頁(yè)簽的顯示方式。 默認(rèn)值:SelectedMode.INDICATOR
board10+[BoardStyle]設(shè)置選中子頁(yè)簽的背板風(fēng)格。子頁(yè)簽的背板風(fēng)格僅在水平模式下有效。
labelStyle10+[LabelStyle]設(shè)置子頁(yè)簽的label文本和字體的樣式。
padding10+[Padding][Dimension]

IndicatorStyle10+對(duì)象說(shuō)明

名稱參數(shù)類型必填描述
color[ResourceColor]下劃線的顏色和背板顏色。 默認(rèn)值:#FF007DFF
height[Length]下劃線的高度(不支持百分比設(shè)置)。 默認(rèn)值:2.0 單位:vp
width[Length]下劃線的寬度(不支持百分比設(shè)置)。 默認(rèn)值:0.0 單位:vp**說(shuō)明:**寬度設(shè)置為0時(shí),按頁(yè)簽文本寬度顯示。
borderRadius[Length]下劃線的圓角半徑(不支持百分比設(shè)置)。 默認(rèn)值:0.0 單位:vp
marginTop[Length]下劃線與文字的間距(不支持百分比設(shè)置)。 默認(rèn)值:8.0 單位:vp

SelectedMode10+枚舉說(shuō)明

名稱描述
INDICATOR使用下劃線模式。
BOARD使用背板模式。

BoardStyle10+對(duì)象說(shuō)明

名稱參數(shù)類型必填描述
borderRadius[Length]背板的圓角半徑(不支持百分比設(shè)置)。 默認(rèn)值:8.0 單位:vp

LabelStyle10+對(duì)象說(shuō)明

名稱參數(shù)類型必填描述
overflow[TextOverflow]設(shè)置Label文本超長(zhǎng)時(shí)的顯示方式。默認(rèn)值是省略號(hào)截?cái)唷?/td>
maxLinesnumber設(shè)置Label文本的最大行數(shù)。如果指定此參數(shù),則文本最多不會(huì)超過(guò)指定的行。如果有多余的文本,可以通過(guò)textOverflow來(lái)指定截?cái)喾绞?。默認(rèn)值是1。
minFontSizenumber[ResourceStr]
maxFontSizenumber[ResourceStr]
heightAdaptivePolicy[TextHeightAdaptivePolicy]設(shè)置Label文本自適應(yīng)高度的方式。默認(rèn)值是最大行數(shù)優(yōu)先。
font[Font]設(shè)置Label文本字體樣式。 當(dāng)頁(yè)簽為子頁(yè)簽時(shí),默認(rèn)值是字體大小16.0fp、字體類型'HarmonyOS Sans',字體風(fēng)格正常,字重正常。 當(dāng)頁(yè)簽為底部頁(yè)簽時(shí),默認(rèn)值是字體大小10.0fp、字體類型'HarmonyOS Sans',字體風(fēng)格正常,字重中等。

BottomTabBarStyle9+

底部頁(yè)簽和側(cè)邊頁(yè)簽樣式。

constructor

constructor(icon: string | Resource, content: string | Resource)

BottomTabBarStyle的構(gòu)造函數(shù)。

參數(shù):

參數(shù)名參數(shù)類型必填參數(shù)描述
iconstring[Resource]
textstring[Resource]

of10+

static of(icon: ResourceStr, text: ResourceStr) BottomTabBarStyle的靜態(tài)構(gòu)造函數(shù)。

參數(shù):

參數(shù)名參數(shù)類型必填參數(shù)描述
icon[ResourceStr]頁(yè)簽內(nèi)的圖片內(nèi)容。
text[ResourceStr]頁(yè)簽內(nèi)的文字內(nèi)容。

屬性

支持以下屬性:

名稱參數(shù)類型描述
padding10+[Padding][Dimension]
verticalAlign10+[VerticalAlign]設(shè)置底部頁(yè)簽的圖片、文字在垂直方向上的對(duì)齊格式。 默認(rèn)值:VerticalAlign.Center
layoutMode10+[LayoutMode]設(shè)置底部頁(yè)簽的圖片、文字排布的方式,具體參照LayoutMode枚舉。 默認(rèn)值:LayoutMode.VERTICAL
symmetricExtensible10+boolean設(shè)置底部頁(yè)簽的圖片、文字是否可以對(duì)稱借左右底部頁(yè)簽的空余位置中的最小值,僅fixed水平模式下在底部頁(yè)簽之間有效。 默認(rèn)值:false
labelStyle10+[LabelStyle]設(shè)置子頁(yè)簽的label文本和字體的樣式。

LayoutMode10+枚舉說(shuō)明

名稱描述
AUTO若頁(yè)簽寬度大于104vp,頁(yè)簽內(nèi)容為左右排布,否則頁(yè)簽內(nèi)容為上下排布。僅TabBar為垂直模式或Fixed水平模式時(shí)有效。
VERTICAL頁(yè)簽內(nèi)容上下排布。
HORIZONAL頁(yè)簽內(nèi)容左右排布。HarmonyOS與OpenHarmony鴻蒙文檔籽料:mau123789是v直接拿

搜狗高速瀏覽器截圖20240326151450.png

示例

示例1

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

  @Builder TabBuilder(index: number) {
    Column() {
      Image(this.currentIndex === index ? '/common/public_icon_on.svg' : '/common/public_icon_off.svg')
        .width(24)
        .height(24)
        .margin({ bottom: 4 })
        .objectFit(ImageFit.Contain)
      Text(`Tab${index + 1}`)
        .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor)
        .fontSize(10)
        .fontWeight(500)
        .lineHeight(14)
    }.width('100%')
  }

  build() {
    Column() {
      Tabs({ barPosition: BarPosition.End, controller: this.controller }) {
        TabContent() {
          Column() {
            Text('Tab1')
              .fontSize(36)
              .fontColor('#182431')
              .fontWeight(500)
              .opacity(0.4)
              .margin({ top: 30, bottom: 56.5 })
            Divider()
              .strokeWidth(0.5)
              .color('#182431')
              .opacity(0.05)
          }.width('100%')
        }.tabBar(this.TabBuilder(0))

        TabContent() {
          Column() {
            Text('Tab2')
              .fontSize(36)
              .fontColor('#182431')
              .fontWeight(500)
              .opacity(0.4)
              .margin({ top: 30, bottom: 56.5 })
            Divider()
              .strokeWidth(0.5)
              .color('#182431')
              .opacity(0.05)
          }.width('100%')
        }.tabBar(this.TabBuilder(1))

        TabContent() {
          Column() {
            Text('Tab3')
              .fontSize(36)
              .fontColor('#182431')
              .fontWeight(500)
              .opacity(0.4)
              .margin({ top: 30, bottom: 56.5 })
            Divider()
              .strokeWidth(0.5)
              .color('#182431')
              .opacity(0.05)
          }.width('100%')
        }.tabBar(this.TabBuilder(2))

        TabContent() {
          Column() {
            Text('Tab4')
              .fontSize(36)
              .fontColor('#182431')
              .fontWeight(500)
              .opacity(0.4)
              .margin({ top: 30, bottom: 56.5 })
            Divider()
              .strokeWidth(0.5)
              .color('#182431')
              .opacity(0.05)
          }.width('100%')
        }.tabBar(this.TabBuilder(3))
      }
      .vertical(false)
      .barHeight(56)
      .onChange((index: number) = > {
        this.currentIndex = index
      })
      .width(360)
      .height(190)
      .backgroundColor('#F1F3F5')
      .margin({ top: 38 })
    }.width('100%')
  }
}

tabContent

示例2

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

  @Builder TabBuilder(index: number) {
    Column() {
      Image(this.currentIndex === index ? '/common/public_icon_on.svg' : '/common/public_icon_off.svg')
        .width(24)
        .height(24)
        .margin({ bottom: 4 })
        .objectFit(ImageFit.Contain)
      Text('Tab')
        .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor)
        .fontSize(10)
        .fontWeight(500)
        .lineHeight(14)
    }.width('100%').height('100%').justifyContent(FlexAlign.Center)
  }

  build() {
    Column() {
      Tabs({ barPosition: BarPosition.Start, controller: this.controller }) {
        TabContent()
          .tabBar(this.TabBuilder(0))
        TabContent()
          .tabBar(this.TabBuilder(1))
        TabContent()
          .tabBar(this.TabBuilder(2))
        TabContent()
          .tabBar(this.TabBuilder(3))
      }
      .vertical(true)
      .barWidth(96)
      .barHeight(414)
      .onChange((index: number) = > {
        this.currentIndex = index
      })
      .width(96)
      .height(414)
      .backgroundColor('#F1F3F5')
      .margin({ top: 52 })
    }.width('100%')
  }
}

tabContent

示例3

// xxx.ets
@Entry
@Component
struct TabBarStyleExample {
  build() {
    Column({ space: 5 }) {
      Text("子頁(yè)簽樣式")
      Column() {
        Tabs({ barPosition: BarPosition.Start }) {
          TabContent() {
            Column().width('100%').height('100%').backgroundColor(Color.Pink)
          }.tabBar(new SubTabBarStyle('Pink'))

          TabContent() {
            Column().width('100%').height('100%').backgroundColor(Color.Yellow)
          }.tabBar(new SubTabBarStyle('Yellow'))

          TabContent() {
            Column().width('100%').height('100%').backgroundColor(Color.Blue)
          }.tabBar(new SubTabBarStyle('Blue'))

          TabContent() {
            Column().width('100%').height('100%').backgroundColor(Color.Green)
          }.tabBar(new SubTabBarStyle('Green'))
        }
        .vertical(false)
        .scrollable(true)
        .barMode(BarMode.Fixed)
        .onChange((index: number) = > {
          console.info(index.toString())
        })
        .width('100%')
        .backgroundColor(0xF1F3F5)
      }.width('100%').height(200)
      Text("底部頁(yè)簽樣式")
      Column() {
        Tabs({ barPosition: BarPosition.End }) {
          TabContent() {
            Column().width('100%').height('100%').backgroundColor(Color.Pink)
          }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'pink'))

          TabContent() {
            Column().width('100%').height('100%').backgroundColor(Color.Yellow)
          }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow'))

          TabContent() {
            Column().width('100%').height('100%').backgroundColor(Color.Blue)
          }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue'))

          TabContent() {
            Column().width('100%').height('100%').backgroundColor(Color.Green)
          }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green'))
        }
        .vertical(false)
        .scrollable(true)
        .barMode(BarMode.Fixed)
        .onChange((index: number) = > {
          console.info(index.toString())
        })
        .width('100%')
        .backgroundColor(0xF1F3F5)
      }.width('100%').height(200)
      Text("側(cè)邊頁(yè)簽樣式")
      Column() {
        Tabs({ barPosition: BarPosition.Start }) {
          TabContent() {
            Column().width('100%').height('100%').backgroundColor(Color.Pink)
          }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'pink'))

          TabContent() {
            Column().width('100%').height('100%').backgroundColor(Color.Yellow)
          }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow'))

          TabContent() {
            Column().width('100%').height('100%').backgroundColor(Color.Blue)
          }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue'))

          TabContent() {
            Column().width('100%').height('100%').backgroundColor(Color.Green)
          }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green'))
        }
        .vertical(true).scrollable(true).barMode(BarMode.Fixed)
        .onChange((index: number) = > {
          console.info(index.toString())
        })
        .width('100%')
        .backgroundColor(0xF1F3F5)
      }.width('100%').height(400)
    }
  }
}

tabbarStyle

示例4

// xxx.ets
@Entry
@Component
struct TabsAttr {
  private controller: TabsController = new TabsController()
  @State indicatorColor: Color = Color.Blue;
  @State indicatorWidth: number = 40;
  @State indicatorHeight: number = 10;
  @State indicatorBorderRadius: number = 5;
  @State indicatorSpace: number = 10;
  @State subTabBorderRadius: number = 20;
  @State selectedMode: SelectedMode = SelectedMode.INDICATOR;
  private colorFlag: boolean = true;
  private widthFlag: boolean = true;
  private heightFlag: boolean = true;
  private borderFlag: boolean = true;
  private spaceFlag: boolean = true;

  build() {
    Column() {
      Button("下劃線顏色變化").width('100%').margin({ bottom: '12vp' })
        .onClick((event?: ClickEvent) = > {
          // 對(duì)Button組件的寬高屬性進(jìn)行動(dòng)畫(huà)配置
          if (this.colorFlag) {
            animateTo({
              duration: 1000, // 動(dòng)畫(huà)時(shí)長(zhǎng)
              curve: Curve.Linear, // 動(dòng)畫(huà)曲線
              delay: 200, // 動(dòng)畫(huà)延遲
              iterations: 1, // 播放次數(shù)
              playMode: PlayMode.Normal, // 動(dòng)畫(huà)模式
              onFinish: () = > {
                console.info('play end')
              }
            }, () = > {
              this.indicatorColor = Color.Red
            })
          } else {
            animateTo({
              duration: 1000, // 動(dòng)畫(huà)時(shí)長(zhǎng)
              curve: Curve.Linear, // 動(dòng)畫(huà)曲線
              delay: 200, // 動(dòng)畫(huà)延遲
              iterations: 1, // 播放次數(shù)
              playMode: PlayMode.Normal, // 動(dòng)畫(huà)模式
              onFinish: () = > {
                console.info('play end')
              }
            }, () = > {
              this.indicatorColor = Color.Yellow
            })
          }
          this.colorFlag = !this.colorFlag
        })
      Button("下劃線高度變化").width('100%').margin({ bottom: '12vp' })
        .onClick((event?: ClickEvent) = > {
          // 對(duì)Button組件的寬高屬性進(jìn)行動(dòng)畫(huà)配置
          if (this.heightFlag) {
            animateTo({
              duration: 1000, // 動(dòng)畫(huà)時(shí)長(zhǎng)
              curve: Curve.Linear, // 動(dòng)畫(huà)曲線
              delay: 200, // 動(dòng)畫(huà)延遲
              iterations: 1, // 播放次數(shù)
              playMode: PlayMode.Normal, // 動(dòng)畫(huà)模式
              onFinish: () = > {
                console.info('play end')
              }
            }, () = > {
              this.indicatorHeight = 20
            })
          } else {
            animateTo({
              duration: 1000, // 動(dòng)畫(huà)時(shí)長(zhǎng)
              curve: Curve.Linear, // 動(dòng)畫(huà)曲線
              delay: 200, // 動(dòng)畫(huà)延遲
              iterations: 1, // 播放次數(shù)
              playMode: PlayMode.Normal, // 動(dòng)畫(huà)模式
              onFinish: () = > {
                console.info('play end')
              }
            }, () = > {
              this.indicatorHeight = 10
            })
          }
          this.heightFlag = !this.heightFlag
        })
      Button("下劃線寬度變化").width('100%').margin({ bottom: '12vp' })
        .onClick((event?: ClickEvent) = > {
          // 對(duì)Button組件的寬高屬性進(jìn)行動(dòng)畫(huà)配置
          if (this.widthFlag) {
            animateTo({
              duration: 1000, // 動(dòng)畫(huà)時(shí)長(zhǎng)
              curve: Curve.Linear, // 動(dòng)畫(huà)曲線
              delay: 200, // 動(dòng)畫(huà)延遲
              iterations: 1, // 播放次數(shù)
              playMode: PlayMode.Normal, // 動(dòng)畫(huà)模式
              onFinish: () = > {
                console.info('play end')
              }
            }, () = > {
              this.indicatorWidth = 30
            })
          } else {
            animateTo({
              duration: 1000, // 動(dòng)畫(huà)時(shí)長(zhǎng)
              curve: Curve.Linear, // 動(dòng)畫(huà)曲線
              delay: 200, // 動(dòng)畫(huà)延遲
              iterations: 1, // 播放次數(shù)
              playMode: PlayMode.Normal, // 動(dòng)畫(huà)模式
              onFinish: () = > {
                console.info('play end')
              }
            }, () = > {
              this.indicatorWidth = 50
            })
          }
          this.widthFlag = !this.widthFlag
        })
      Button("下劃線圓角半徑變化").width('100%').margin({ bottom: '12vp' })
        .onClick((event?: ClickEvent) = > {
          // 對(duì)Button組件的寬高屬性進(jìn)行動(dòng)畫(huà)配置
          if (this.borderFlag) {
            animateTo({
              duration: 1000, // 動(dòng)畫(huà)時(shí)長(zhǎng)
              curve: Curve.Linear, // 動(dòng)畫(huà)曲線
              delay: 200, // 動(dòng)畫(huà)延遲
              iterations: 1, // 播放次數(shù)
              playMode: PlayMode.Normal, // 動(dòng)畫(huà)模式
              onFinish: () = > {
                console.info('play end')
              }
            }, () = > {
              this.indicatorBorderRadius = 0
            })
          } else {
            animateTo({
              duration: 1000, // 動(dòng)畫(huà)時(shí)長(zhǎng)
              curve: Curve.Linear, // 動(dòng)畫(huà)曲線
              delay: 200, // 動(dòng)畫(huà)延遲
              iterations: 1, // 播放次數(shù)
              playMode: PlayMode.Normal, // 動(dòng)畫(huà)模式
              onFinish: () = > {
                console.info('play end')
              }
            }, () = > {
              this.indicatorBorderRadius = 5
            })
          }
          this.borderFlag = !this.borderFlag
        })
      Button("下劃線間距變化").width('100%').margin({ bottom: '12vp' })
        .onClick((event?: ClickEvent) = > {
          // 對(duì)Button組件的寬高屬性進(jìn)行動(dòng)畫(huà)配置
          if (this.spaceFlag) {
            animateTo({
              duration: 1000, // 動(dòng)畫(huà)時(shí)長(zhǎng)
              curve: Curve.Linear, // 動(dòng)畫(huà)曲線
              delay: 200, // 動(dòng)畫(huà)延遲
              iterations: 1, // 播放次數(shù)
              playMode: PlayMode.Normal, // 動(dòng)畫(huà)模式
              onFinish: () = > {
                console.info('play end')
              }
            }, () = > {
              this.indicatorSpace = 20
            })
          } else {
            animateTo({
              duration: 1000, // 動(dòng)畫(huà)時(shí)長(zhǎng)
              curve: Curve.Linear, // 動(dòng)畫(huà)曲線
              delay: 200, // 動(dòng)畫(huà)延遲
              iterations: 1, // 播放次數(shù)
              playMode: PlayMode.Normal, // 動(dòng)畫(huà)模式
              onFinish: () = > {
                console.info('play end')
              }
            }, () = > {
              this.indicatorSpace = 10
            })
          }
          this.spaceFlag = !this.spaceFlag
        })
      Tabs({ barPosition: BarPosition.End, controller: this.controller }) {
        TabContent() {
          Column().width('100%').height('100%').backgroundColor(Color.Pink).borderRadius('12vp')
        }.tabBar(SubTabBarStyle.of('pink')
          .indicator({
            color: this.indicatorColor, //下劃線顏色
            height: this.indicatorHeight, //下劃線高度
            width: this.indicatorWidth, //下劃線寬度
            borderRadius: this.indicatorBorderRadius, //下劃線圓角半徑
            marginTop: this.indicatorSpace //下劃線與文字間距
          })
          .selectedMode(this.selectedMode)
          .board({ borderRadius: this.subTabBorderRadius })
          .labelStyle({})
        )

        TabContent() {
          Column().width('100%').height('100%').backgroundColor(Color.Yellow).borderRadius('12vp')
        }.tabBar('yellow')

        TabContent() {
          Column().width('100%').height('100%').backgroundColor(Color.Blue).borderRadius('12vp')
        }.tabBar('blue')

        TabContent() {
          Column().width('100%').height('100%').backgroundColor(Color.Green).borderRadius('12vp')
        }.tabBar('green')

        TabContent() {
          Column().width('100%').height('100%').backgroundColor(Color.Gray).borderRadius('12vp')
        }.tabBar('gray')

        TabContent() {
          Column().width('100%').height('100%').backgroundColor(Color.Orange).borderRadius('12vp')
        }.tabBar('orange')
      }
      .vertical(false)
      .scrollable(true)
      .barMode(BarMode.Scrollable)
      .barHeight(140)
      .animationDuration(400)
      .onChange((index: number) = > {
        console.info(index.toString())
      })
      .backgroundColor(0xF5F5F5)
      .height(320)
    }.width('100%').height(250).padding({ top: '24vp', left: '24vp', right: '24vp' })
  }
}

tabContent3

示例5

// xxx.ets
@Entry
@Component
struct TabsTextOverflow {
  @State message: string = 'Hello World'
  private controller: TabsController = new TabsController()
  @State subTabOverflowOpaque: boolean = true;
  build() {
    Column() {
      Tabs({ barPosition: BarPosition.Start, controller: this.controller }) {
        TabContent() {
          Column(){
            Text('單行省略號(hào)截?cái)?).fontSize(30).fontColor(0xFF000000)
          }.width('100%').height('100%').backgroundColor(Color.Pink)
        }.tabBar(SubTabBarStyle.of('開(kāi)始【單行省略號(hào)截?cái)鄦涡惺÷蕴?hào)截?cái)鄦涡惺÷蕴?hào)截?cái)鄦涡惺÷蕴?hào)截?cái)鄦涡惺÷蕴?hào)截?cái)鄦涡惺÷蕴?hào)截?cái)鄦涡惺÷蕴?hào)截?cái)鄦涡惺÷蕴?hào)截?cái)鄦涡惺÷蕴?hào)截?cái)鄦涡惺÷蕴?hào)截?cái)唷拷Y(jié)束')
          .labelStyle({ overflow: TextOverflow.Ellipsis, maxLines: 1, minFontSize: 10, heightAdaptivePolicy: TextHeightAdaptivePolicy.MAX_LINES_FIRST,
            font: { size: 20 } }))
        TabContent() {
          Column()
          {
            Text('先縮小再截?cái)?).fontSize(30).fontColor(0xFF000000)
          }.width('100%').height('100%').backgroundColor(Color.Pink)
        }.tabBar(SubTabBarStyle.of('開(kāi)始【先縮小再截?cái)嘞瓤s小再截?cái)嘞瓤s小再截?cái)嘞瓤s小再截?cái)嘞瓤s小再截?cái)嘞瓤s小再截?cái)嘞瓤s小再截?cái)嘞瓤s小再截?cái)嘞瓤s小再截?cái)嘞瓤s小再截?cái)嘞瓤s小再截?cái)嘞瓤s小再截?cái)嘞瓤s小再截?cái)嘞瓤s小再截?cái)唷拷Y(jié)束')
          .labelStyle({ overflow: TextOverflow.Clip, maxLines: 1, minFontSize: 15, maxFontSize: 15, heightAdaptivePolicy: TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST,
            font: { size: 20 } }))
        TabContent() {
          Column(){
            Text('先縮小再換行再截?cái)?).fontSize(30).fontColor(0xFF000000)
          }.width('100%').height('100%').backgroundColor(Color.Pink)
        }.tabBar(SubTabBarStyle.of('開(kāi)始【先縮小再換行再截?cái)嘞瓤s小再換行再截?cái)嘞瓤s小再換行再截?cái)嘞瓤s小再換行再截?cái)嘞瓤s小再換行再截?cái)嘞瓤s小再換行再截?cái)嘞瓤s小再換行再截?cái)嘞瓤s小再換行再截?cái)唷拷Y(jié)束')
          .labelStyle({ overflow: TextOverflow.Clip, maxLines: 2, minFontSize: 15, maxFontSize: 15, heightAdaptivePolicy: TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST,
            font: { size: 20 } }))
        TabContent() {
          Column() {
            Text('換行').fontSize(30).fontColor(0xFF000000)
          }
          .width('100%').height('100%').backgroundColor(Color.Pink)
        }.tabBar(SubTabBarStyle.of('開(kāi)始【換行換行換行換行換行換行換行換行換行換行換行換行換行換行換行】結(jié)束')
          .labelStyle({ overflow: TextOverflow.Clip, maxLines: 10, minFontSize: 10, heightAdaptivePolicy: TextHeightAdaptivePolicy.MAX_LINES_FIRST,
            font: { size: 20 } }))
      }
      .vertical(true).scrollable(true)
      .barMode(BarMode.Fixed)
      .barHeight(720)
      .barWidth(200).animationDuration(400)
      .onChange((index: number) = > {
        console.info(index.toString())
      })
      .height('100%').width('100%')
    }
    .height('100%')
  }
}

tabContent4

示例6

// xxx.ets
@Entry
@Component
struct TabContentExample6 {
  private controller: TabsController = new TabsController()
  @State text: string = "2"
  @State tabPadding: number = 0;
  @State symmetricExtensible: boolean = false;
  @State layoutMode: LayoutMode = LayoutMode.VERTICAL;
  @State verticalAlign: VerticalAlign = VerticalAlign.Center;

  build() {
    Column() {
      Row() {
        Button("padding+10 " + this.tabPadding)
          .width('47%')
          .height(50)
          .margin({ top: 5 })
          .onClick((event?: ClickEvent) = > {
            this.tabPadding += 10
          })
          .margin({ right: '6%', bottom: '12vp' })
        Button("padding-10 " + this.tabPadding)
          .width('47%')
          .height(50)
          .margin({ top: 5 })
          .onClick((event?: ClickEvent) = > {
            this.tabPadding -= 10
          })
          .margin({ bottom: '12vp' })
      }

      Row() {
        Button("文本增加 ")
          .width('47%')
          .height(50)
          .margin({ top: 5 })
          .onClick((event?: ClickEvent) = > {
            this.text += '文本增加'
          })
          .margin({ right: '6%', bottom: '12vp' })
        Button("文本重置")
          .width('47%')
          .height(50)
          .margin({ top: 5 })
          .onClick((event?: ClickEvent) = > {
            this.text = "2"
          })
          .margin({ bottom: '12vp' })
      }

      Row() {
        Button("symmetricExtensible改變 " + this.symmetricExtensible)
          .width('100%')
          .height(50)
          .margin({ top: 5 })
          .onClick((event?: ClickEvent) = > {
            this.symmetricExtensible = !this.symmetricExtensible
          })
          .margin({ bottom: '12vp' })
      }

      Row() {
        Button("layoutMode垂直 ")
          .width('47%')
          .height(50)
          .margin({ top: 5 })
          .onClick((event?: ClickEvent) = > {
            this.layoutMode = LayoutMode.VERTICAL;
          })
          .margin({ right: '6%', bottom: '12vp' })
        Button("layoutMode水平 ")
          .width('47%')
          .height(50)
          .margin({ top: 5 })
          .onClick((event?: ClickEvent) = > {
            this.layoutMode = LayoutMode.HORIZONTAL;
          })
          .margin({ bottom: '12vp' })
      }

      Row() {
        Button("verticalAlign朝上")
          .width('100%')
          .height(50)
          .margin({ top: 5 })
          .onClick((event?: ClickEvent) = > {
            this.verticalAlign = VerticalAlign.Top;
          })
          .margin({ bottom: '12vp' })
      }

      Row() {
        Button("verticalAlign居中")
          .width('100%')
          .height(50)
          .margin({ top: 5 })
          .onClick((event?: ClickEvent) = > {
            this.verticalAlign = VerticalAlign.Center;
          })
          .margin({ bottom: '12vp' })
      }

      Row() {
        Button("verticalAlign朝下")
          .width('100%')
          .height(50)
          .margin({ top: 5 })
          .onClick((event?: ClickEvent) = > {
            this.verticalAlign = VerticalAlign.Bottom;
          })
          .margin({ bottom: '12vp' })
      }


      Tabs({ barPosition: BarPosition.End, controller: this.controller }) {
        TabContent() {
          Column().width('100%').height('100%').backgroundColor(Color.Pink)
        }.tabBar(BottomTabBarStyle.of($r("sys.media.ohos_app_icon"), "1"))

        TabContent() {
          Column().width('100%').height('100%').backgroundColor(Color.Green)
        }.tabBar(BottomTabBarStyle.of($r("sys.media.ohos_app_icon"), this.text)
          .padding(this.tabPadding)
          .verticalAlign(this.verticalAlign)
          .layoutMode(this.layoutMode)
          .symmetricExtensible(this.symmetricExtensible))

        TabContent() {
          Column().width('100%').height('100%').backgroundColor(Color.Blue)
        }.tabBar(BottomTabBarStyle.of($r("sys.media.ohos_app_icon"), "3"))
      }
      .animationDuration(300)
      .height('60%')
      .backgroundColor(0xf1f3f5)
      .barMode(BarMode.Fixed)
    }
    .width('100%')
    .height(500)
    .margin({ top: 5 })
    .padding('24vp')
  }
}

審核編輯 黃宇

聲明:本文內(nèi)容及配圖由入駐作者撰寫(xiě)或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • 組件
    +關(guān)注

    關(guān)注

    1

    文章

    532

    瀏覽量

    18424
  • 鴻蒙
    +關(guān)注

    關(guān)注

    60

    文章

    2620

    瀏覽量

    44058
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評(píng)論

    相關(guān)推薦
    熱點(diǎn)推薦

    HarmonyOS/OpenHarmony原生應(yīng)用-ArkTS萬(wàn)能卡片組件Badge

    可以附加在單個(gè)組件上用于信息標(biāo)記的容器組件。該組件從API Version 7開(kāi)始支持。 支持單個(gè)子組件。子
    發(fā)表于 09-28 11:53

    鴻蒙ArkTS容器組件:Column

    沿垂直方向布局的容器。
    的頭像 發(fā)表于 07-05 16:32 ?926次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>容器</b><b class='flag-5'>組件</b>:Column

    鴻蒙ArkTS容器組件:Flex

    以彈性方式布局子組件容器組件。
    的頭像 發(fā)表于 07-08 10:19 ?961次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>容器</b><b class='flag-5'>組件</b>:Flex

    鴻蒙ArkTS容器組件:GridCol

    柵格子組件,必須作為柵格容器組件([GridRow])的子組件使用。
    的頭像 發(fā)表于 07-08 15:17 ?855次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>容器</b><b class='flag-5'>組件</b>:GridCol

    鴻蒙ArkTS容器組件:GridItem

    網(wǎng)格容器中單項(xiàng)內(nèi)容容器。
    的頭像 發(fā)表于 07-09 09:25 ?797次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>容器</b><b class='flag-5'>組件</b>:GridItem

    鴻蒙ArkTS容器組件:ListItemGroup

    組件用來(lái)展示列表item分組,寬度默認(rèn)充滿[List]組件,必須配合List組件來(lái)使用。
    的頭像 發(fā)表于 07-10 09:20 ?1340次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>容器</b><b class='flag-5'>組件</b>:ListItemGroup

    鴻蒙ArkTS容器組件:Navigator

    路由容器組件,提供路由跳轉(zhuǎn)能力。
    的頭像 發(fā)表于 07-10 14:55 ?784次閱讀

    鴻蒙ArkTS容器組件:Refresh

    可以進(jìn)行頁(yè)面下拉操作并顯示刷新動(dòng)效的容器組件。
    的頭像 發(fā)表于 07-11 16:11 ?916次閱讀

    鴻蒙ArkTS容器組件:RowSplit

    將子組件橫向布局,并在每個(gè)子組件之間插入一根縱向的分割線。
    的頭像 發(fā)表于 07-11 22:25 ?694次閱讀

    鴻蒙ArkTS容器組件:Scroll

    可滾動(dòng)的容器組件,當(dāng)子組件的布局尺寸超過(guò)父組件的尺寸時(shí),內(nèi)容可以滾動(dòng)。
    的頭像 發(fā)表于 07-12 15:24 ?2087次閱讀

    鴻蒙ArkTS容器組件:SideBarContainer

    提供側(cè)邊欄可以顯示和隱藏的側(cè)邊欄容器,通過(guò)子組件定義側(cè)邊欄和內(nèi)容區(qū),第一個(gè)子組件表示側(cè)邊欄,第二個(gè)子組件表示內(nèi)容區(qū)。
    的頭像 發(fā)表于 07-18 15:46 ?1086次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>容器</b><b class='flag-5'>組件</b>:SideBarContainer

    鴻蒙ArkTS容器組件:Stack

    堆疊容器,子組件按照順序依次入棧,后一個(gè)子組件覆蓋前一個(gè)子組件
    的頭像 發(fā)表于 07-15 18:23 ?1404次閱讀

    鴻蒙ArkTS容器組件:Swiper

    滑塊視圖容器,提供子組件滑動(dòng)輪播顯示的能力。
    的頭像 發(fā)表于 07-15 09:51 ?1406次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>容器</b><b class='flag-5'>組件</b>:Swiper

    鴻蒙ArkTS容器組件:Tabs

    通過(guò)頁(yè)簽進(jìn)行內(nèi)容視圖切換的容器組件,每個(gè)頁(yè)簽對(duì)應(yīng)一個(gè)內(nèi)容視圖。
    的頭像 發(fā)表于 07-15 09:48 ?1740次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>容器</b><b class='flag-5'>組件</b>:Tabs

    鴻蒙ArkTS容器組件:WaterFlow

    瀑布流容器,由“行”和“列”分割的單元格所組成,通過(guò)容器自身的排列規(guī)則,將不同大小的“項(xiàng)目”自上而下,如瀑布般緊密布局。
    的頭像 發(fā)表于 07-15 17:35 ?813次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>容器</b><b class='flag-5'>組件</b>:WaterFlow