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%")
  }
}
分享
微博
QQ
微信
回复
2024-12-24 18:48:11
相关问题
HarmonyOS Scroll中嵌套List滑动事件冲突
210浏览 • 1回复 待解决
HarmonyOS scrolllist滚动冲突
689浏览 • 1回复 待解决
Scroll内Flex加宽高与滑动冲突
2237浏览 • 1回复 待解决
HarmonyOS Grid横向滑动
706浏览 • 1回复 待解决
HarmonyOS tabsgrid实现滑动
241浏览 • 1回复 待解决
scrolllist的嵌套滑动
1932浏览 • 1回复 待解决
HarmonyOS 横向Scroll定位到最右侧
137浏览 • 1回复 待解决
HarmonyOS image图片纵向横向滑动
163浏览 • 1回复 待解决
HarmonyOS 滑动事件冲突
349浏览 • 1回复 待解决
HarmonyOS 滑动冲突问题
826浏览 • 1回复 待解决
HarmonyOS Scroll嵌套web手势冲突
183浏览 • 1回复 待解决
HarmonyOS TabsWeb嵌套左右滑动问题
537浏览 • 1回复 待解决
HarmonyOS 父子组件滑动冲突
284浏览 • 1回复 待解决
HarmonyOS scroll滑动问题
710浏览 • 1回复 待解决