HarmonyOS Tabs和横向Scroll滑动冲突

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

可参考示例:

const tabList: Array<string> = ["综合", "产品", "资讯", "价格"];
@Entry
@Component
struct Index9{
  private tabController: TabsController = new TabsController();
  @State currentIndex: number = 0;
  scroller: Scroller = new Scroller()
  build() {
    Tabs({ barPosition: BarPosition.Start, index: this.currentIndex, controller: this.tabController }) {
      TabContent() {
        Column(){
          Scroll(this.scroller){
            Row(){
              Text("全部")
                .fontSize(14)
                .padding({ left: 10, right: 10, top: 5, bottom: 5 })
                .borderRadius(3)
                .onClick(() => {
                })

              Text("最近一周")
                .fontSize(14)
                .padding({ left: 10, right: 10, top: 5, bottom: 5 })
                .borderRadius(3)
                .onClick(() => {
                })

              Text("最近30天")
                .fontSize(14)
                .padding({ left: 10, right: 10, top: 5, bottom: 5 })
                .borderRadius(3)
                .onClick(() => {
                })

              Text("最近半年")
                .fontSize(14)
                .padding({ left: 10, right: 10, top: 5, bottom: 5 })
                .borderRadius(3)
                .onClick(() => {
                })

              Text("自选时间")
                .fontSize(14)
                .padding({ left: 10, right: 10, top: 5, bottom: 5 })
                .borderRadius(3)
                .onClick(() => {
                })

              Row(){
                Text("开始时间")
                  .fontSize(14)
                  .padding({ left: 10, right: 10, top: 5, bottom: 5 })
                  .onClick(() => {
                  })

                Divider()
                  .strokeWidth(0.5)
                  .width(7)
                  .margin({left: 3, right: 3})

                Text("结束时间")
                  .fontSize(14)
                  .padding({ left: 10, right: 10, top: 5, bottom: 5 })
                  .onClick(() => {
                  })
              }
              .alignItems(VerticalAlign.Center)
              .margin({left: 15, right: 15})
            }
            .margin({top: 10, bottom: 10, left: 20, right: 20})
          }
          .scrollBar(BarState.Off)
          .scrollable(ScrollDirection.Horizontal)
          .edgeEffect(EdgeEffect.Spring)

          Text("第一页")
        }
        .width("100%")
        .height("100%")
      }
      .tabBar(this.tabBuilder(0, tabList[0]))

      TabContent() {

      }
      .tabBar(this.tabBuilder(1, tabList[1]))

      TabContent() {

      }
      .tabBar(this.tabBuilder(2, tabList[2]))

      TabContent() {

      }
      .tabBar(this.tabBuilder(3, tabList[3]))
    }
    .width("100%")
    .height("100%")
    .barMode(BarMode.Fixed)
    .onChange((index: number) => {
      this.currentIndex = index;
    })
  }

  @Builder
  tabBuilder(index: number, name: string) {
    Column() {
      Text(name)
        .fontColor("#121212")
        .fontSize(16)
      Column()
        .width(25)
        .height(4)
        .borderRadius(2)
        .linearGradient({
          direction: GradientDirection.Right, // 渐变方向
          repeating: false, // 渐变颜色是否重复
          colors: [[0xFF8800, 0.0], [0xD23023, 1]] // 数组末尾元素占比小于1时满足重复着色效果
        })
        .opacity(this.currentIndex === index ? 1 : 0)
        .margin({top: 7})

      Divider()
        .strokeWidth(0.5)
        .width("100%")
        .color("#F2F2F2")
    }
    .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.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
  • 105.
  • 106.
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
  • 114.
  • 115.
  • 116.
  • 117.
  • 118.
  • 119.
  • 120.
  • 121.
  • 122.
  • 123.
  • 124.
  • 125.
  • 126.
  • 127.
  • 128.
  • 129.
  • 130.
  • 131.
分享
微博
QQ
微信
回复
2024-12-24 18:48:11
相关问题
HarmonyOS Scroll中嵌套List滑动事件冲突
816浏览 • 1回复 待解决
HarmonyOS scrolllist滚动冲突
1127浏览 • 1回复 待解决
Scroll内Flex加宽高与滑动冲突
2735浏览 • 1回复 待解决
HarmonyOS Grid横向滑动
1179浏览 • 1回复 待解决
scrolllist的嵌套滑动
2560浏览 • 1回复 待解决
HarmonyOS tabsgrid实现滑动
620浏览 • 1回复 待解决
HarmonyOS 横向Scroll定位到最右侧
517浏览 • 1回复 待解决
HarmonyOS Scroll嵌套web手势冲突
683浏览 • 1回复 待解决
HarmonyOS 滑动事件冲突
901浏览 • 1回复 待解决
HarmonyOS 滑动冲突问题
1322浏览 • 1回复 待解决
HarmonyOS image图片纵向横向滑动
591浏览 • 1回复 待解决
HarmonyOS 父子组件滑动冲突
756浏览 • 1回复 待解决
HarmonyOS TabsWeb嵌套左右滑动问题
903浏览 • 1回复 待解决
HarmonyOS Scroll组件无法滑动
1191浏览 • 1回复 待解决
HarmonyOS scroll滑动问题
1125浏览 • 1回复 待解决