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%' })
  }
}
分享
微博
QQ
微信
回复
2025-01-09 17:48:17
相关问题
HarmonyOS GridItem之间一条竖线
192浏览 • 1回复 待解决
HarmonyOS如何去掉List组件滑动线
1250浏览 • 1回复 待解决
HarmonyOS Web组件如何附加请求头header
428浏览 • 1回复 待解决
HarmonyOS 折叠
238浏览 • 1回复 待解决
HarmonyOS Video组件能否设置自定义header
743浏览 • 1回复 待解决
HarmonyOS 如何绘制一条虚线
451浏览 • 1回复 待解决
HarmonyOS设置webview请求头header
1256浏览 • 1回复 待解决