HarmonyOS List、Row、Column等排列组件内两个相邻的子组件之间有间隙?

List、Row、Column等排列组件内两个相邻的子组件之间有间隙,两个子组件都是相同色值的背景,但部署到真机或者模拟器时未完全拼接,中间有1px左右的间隙。

阅读 610
1 个回答

可以给组件设置以下属性可以解决显示的间隙问题:.pixelRound({ top:PixelRoundCalcPolicy.FORCE\_FLOOR, end:PixelRoundCalcPolicy.FORCE\_CEIL })

文档: https://developer.huawei.com/consumer/cn/doc/harmonyos-references/ts-universal-attributes-layout-constraints-0000001815927508\#ZH-CN\_TOPIC\_0000001815927508\_\_pixelround11

参考代码:

Row() {
  Text('返回')
    .textAlign(TextAlign.Center)
    .height('100%')
    .aspectRatio(1)
    .fontColor('#FFCB88')
    .fontSize(11)
    .backgroundColor('#112e53')
  Image($r('app.media.img_fan'))
    .aspectRatio(0.72)
    .height('100%')
    .objectFit(ImageFit.Cover)
    .pixelRound({ top:PixelRoundCalcPolicy.FORCE_FLOOR, end:PixelRoundCalcPolicy.FORCE_CEIL })
  Text('¥' + 8.12)
    .height('100%')
    .padding({left:3, right:3})
    .fontColor(Color.White)
    .fontSize(11)
    .backgroundColor('#8156f2')
    .textAlign(TextAlign.Center)
    .pixelRound({ top:PixelRoundCalcPolicy.FORCE_FLOOR, end:PixelRoundCalcPolicy.FORCE_CEIL })
}.margin({right:10})
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进