HarmonyOS List组件Header吸顶时,Header与其上方组件之间会存一条线的在间隙

List组件Header吸顶时,Header与其上方组件之间会存一条线的在间隙,请问有什么办法处理么

HarmonyOS  List组件Header吸顶时,Header与其上方组件之间会存一条线的在间隙 -鸿蒙开发者社区

HarmonyOS
2025-01-09 15:48:33
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
aquaa

可以增加 .pixelRound属性,设置向下取整即可。

参考文档:

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-universal-attributes-layout-constraints-V5#pixelround11

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-appendix-enums-V5#pixelroundcalcpolicy11

示例Demo代码:

@Entry
@Component
export struct ListHeaderPage {
  array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  @Builder
  Header() {
    Text('Header,可吸顶').size({ width: '100%', height: 30 })
      .backgroundColor('#ff0000')
  }
  build() {
    Column() {
      Text('List上方组件').size({ width: '100%', height: 30 })
        .backgroundColor('#ff0000')
      List() {
        ListItem().backgroundColor('#FFFFFF')
          .size({ width: '100%', height: 30 })
        ListItemGroup({ header: this.Header() }) {
          ForEach(this.array, (value: number) => {
            ListItem(){
              Text('ListItem').size({ width: '100%', height: 50 })
                .backgroundColor('#ffff00')
                .margin({ top: 5 })
            }
          })
        }
        .pixelRound({
          start:PixelRoundCalcPolicy.FORCE_FLOOR,
          top:PixelRoundCalcPolicy.FORCE_FLOOR,
          end: PixelRoundCalcPolicy.FORCE_FLOOR,
          bottom: PixelRoundCalcPolicy.FORCE_FLOOR
        })
      }
      .scrollBar(BarState.Off)
      .sticky(StickyStyle.Header)
      .edgeEffect(EdgeEffect.None)
      .width('100%')
      .height('100%')
    }
    .size({ 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.
分享
微博
QQ
微信
回复
2025-01-09 17:48:17
相关问题
HarmonyOS GridItem之间一条竖线
650浏览 • 1回复 待解决
HarmonyOS如何去掉List组件滑动线
1746浏览 • 1回复 待解决
HarmonyOS Web组件如何附加请求头header
907浏览 • 1回复 待解决
HarmonyOS 怎么给web组件请求添加header
1218浏览 • 1回复 待解决
HarmonyOS 折叠
523浏览 • 1回复 待解决
HarmonyOS Video组件能否设置自定义header
1119浏览 • 1回复 待解决
HarmonyOS 如何绘制一条虚线
857浏览 • 1回复 待解决
HarmonyOS设置webview请求头header
1933浏览 • 1回复 待解决