【每日学点HarmonyOS Next知识】Web交互、列表拖拽、横屏后布局、Event序列问题、Scroll与Web组合

发布于:2025-03-10 ⋅ 阅读:(19) ⋅ 点赞:(0)
1、HarmonyOS list组件如何设置匀速滑动?

edgeEffect.None 这个属性是设置边缘滑动效果,支持弹簧效果和阴影效果。

friction:设置摩擦系数,手动划动滚动区域时生效,只对惯性滚动过程有影响,对惯性滚动过程中的链式效果有间接影响。

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-container-list-V5#listscroller11%E5%AF%B9%E8%B1%A1%E8%AF%B4%E6%98%8E

![[Pasted image 20250126181910.png]]

2、HarmonyOS router怎么判断某个Page是否启动了 还在路由栈里面?

router怎么判断某个Page是否启动了,还在路由栈里面,需要知道某个Entry组件是否还存活了。
router不支持判断是否在路由栈中的方法,建议你尽量用navigation来实现,因为后续router会停止演进,后续也不会新增能力。navigation中可以通过getAllPathName 获取栈中所有NavDestination页面的名称。

参考地址:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-navigation-V5#getallpathname10

3、HarmonyOS 如何在Tabs导航栏顶部加一条横线?

如何在Tabs导航栏顶部加一条横线。
可以添加一个边框样式,可参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-universal-attributes-border-V5

参考demo:

.border({
  width: { left: 0, right: 0, top: 3, bottom: 0 },
  color: {left:Color.White, right:Color.White, top: Color.Red, bottom:Color.White},
  style: {
    top: BorderStyle.Solid,
  }
})
4、HarmonyOS 触摸滑动与滚动组件冲突问题?

父组件A,在onTouch事件中执行下拉上滑移动A组件,子组件B(Scroll、Web等)的滚动和父组件的拖动会同时出现,如何避免该手势的冲突

可以参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-gesture-events-multi-level-gesture-V5
在这里插入图片描述

5、HarmonyOS Progress 怎样自定义圆角大小?

Progress 怎样自定义圆角大小ProgressType.Linear怎么实现大小16x8 圆角2的效果。
参考demo:

// xxx.ets
@Entry
@Component
struct ProgressExample {
  build() {
    Column({ space: 15 }) {
      Text('Linear Progress').fontSize(9).fontColor(0xCCCCCC).width('90%')
      Progress({ value: 20, total: 100, type: ProgressType.Linear })
        .width(200)
        .backgroundColor('#B3E54C')
        .style({ strokeRadius: 0, strokeWidth: 100 ,})
        .color('#917AF9')
        .borderColor('#00000000')
        .borderRadius(20)
        .clip(true)
    }.width('100%').margin({ top: 30 })
  }
}