HarmonyOS scroll和list滚动冲突

Scroll() {  
      Column() {  
        CommonTitleBar({  
          attribute: {  
            bg_color: $r('app.color.color_ffffff'),  
            close_text: '',  
            closeCallback: () => {  
              router.back()  
            },  
            title_text: '通讯录',  
            isVisibleMoreOrRightText: true,  
            isVisibleMore: true,  
            rightImage: $r('app.media.icon_mail_list_more'),  
            rightTextClick: () => {  
              router.pushUrl({  
                url: CommonConstants.INVITE_AND_APPLY  
              })  
            }  
          }  
        }).height(48)  
          .width('100%')  
        Divider().color($r('app.color.color_f5f5f5')).strokeWidth(5)  
          
        Column() {  
          Text('常用联系人')  
            .fontColor('#FF999999')  
            .fontSize(14)  
            .textAlign(TextAlign.Start)  
            .padding({  
              top: 16  
            })  
            .width('95%')  
          List() {  
            ForEach(this.recentContactsList, (recentContactsList: RecentContactsEntity, index: number) => {  
              ListItem() {  
                this.itemCell(recentContactsList, index)  
              }  
            }, (item: RecentContactsEntity) => JSON.stringify(item))  
          }  
          .padding({ bottom: 106, top: 10})  
        }  
        .width('95%')  
        .backgroundColor('#ffffff')  
        .borderRadius(6)  
        .margin({  
          top: 16  
        })  
  }.backgroundColor($r('app.color.color_f5f5f5'))  
      .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.

类似上述代码,scroll里嵌套list,怎么禁止list的滑动,只使用scroll的滑动。

HarmonyOS
2024-09-30 11:47:09
1124浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Heiang

scroll嵌套list的时候,若List不设置宽高,则默认全部加载,不会滚动。demo如下:

@Entry  
@Component  
struct NestedScroll {  
  @State listPosition: number = 0; // 0代表滚动到List顶部,1代表中间值,2代表滚动到List底部。  
  private arr: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]  
  private scrollerForScroll: Scroller = new Scroller()  
  private scrollerForList: Scroller = new Scroller()  
  build() {  
    Flex() {  
      Scroll(this.scrollerForScroll) {  
        Column() {  
          Text("Scroll Area")  
            .width("100%")  
            .height("40%")  
            .backgroundColor(0X330000FF)  
            .fontSize(16)  
            .textAlign(TextAlign.Center)  
          List({ space: 20, scroller: this.scrollerForList }) {  
            ForEach(this.arr, (item: number) => {  
              ListItem() {  
                Text("ListItem" + item)  
                  .width("100%")  
                  .height("100%")  
                  .borderRadius(15)  
                  .fontSize(16)  
                  .textAlign(TextAlign.Center)  
                  .backgroundColor(Color.White)  
              }.width("100%").height(100)  
            }, (item: string) => item)  
          }  
          .width("100%")  
          Text("Scroll Area")  
            .width("100%")  
            .height("40%")  
            .backgroundColor(0X330000FF)  
            .fontSize(16)  
            .textAlign(TextAlign.Center)  
        }  
      }  
      .width("100%")  
      .height("100%")  
    }.width('100%').height('100%').backgroundColor(0xDCDCDC).padding(20)  
  }  
}
  • 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.
分享
微博
QQ
微信
回复
2024-09-30 17:05:37
相关问题
HarmonyOS Scroll中嵌套List滑动事件冲突
811浏览 • 1回复 待解决
HarmonyOS Tabs横向Scroll滑动冲突
821浏览 • 1回复 待解决
HarmonyOS 嵌套滚动冲突
869浏览 • 1回复 待解决
WebList嵌套手势冲突问题
1682浏览 • 1回复 待解决
scrolllist的嵌套滑动
2547浏览 • 1回复 待解决
ArkTS UI的List集合List冲突的问题
1306浏览 • 1回复 待解决
HarmonyOS Scroll嵌套web手势冲突
681浏览 • 1回复 待解决
HarmonyOS scroll滚动问题
700浏览 • 1回复 待解决
HarmonyOS Scroll组件滚动控制
929浏览 • 1回复 待解决
HarmonyOS Scroll组件滚动问题
1426浏览 • 1回复 待解决
HarmonyOS list嵌套MapComponent滑动冲突
581浏览 • 1回复 待解决