HarmonyNext使用ListItemGroup添加头部 布局,头部布局底部留很大空白

今天使用ListItemGroup添加头部布局的时候,发现底部留下很多空白

头部布局使用的是相对布局RelativeContainer

错误代码如下:

import { CommonConstants } from "@ohos/utils/src/main/ets/common/CommonConstants";
import { DisPlayInfo } from "@ohos/utils/src/main/ets/utils/DisPlayInfo";
import { DisplayUtil } from "@pura/harmony-utils";

@ComponentV2
export struct HomePages {
  displayInfo: DisPlayInfo = new DisPlayInfo()

  build() {
    Column() {
      List() {
        ListItemGroup({ header: this.homeHead() }) {
          ForEach(['0', '1', '2', '3', '4'], (item: string, index: number) => {
            ListItem() {
              Row() {
                RelativeContainer() {
                  Image($r('app.media.icon_home_test')).size({ width: 50, height: CommonConstants.FULL_PERCENT })
                    .borderRadius(8)
                    .id('iv_list_cover')


                }.layoutWeight(1).height(CommonConstants.FULL_PERCENT)

                Text('免费')
                  .size({ width: this.displayInfo.getWidth(48), height: this.displayInfo.getWidth(22) })
                  .backgroundColor($r('app.color.black_22252a'))
                  .fontColor($r('app.color.color_white'))
                  .fontSize(12)
                  .textAlign(TextAlign.Center)
                  .borderRadius(19)

              }.padding({ left: 16, right: 16 })
              .width(CommonConstants.FULL_PERCENT).height(this.displayInfo.getWidth(50))
              .alignItems(VerticalAlign.Center)

            }

          })

        }

      }.listDirection(Axis.Vertical)
      .layoutWeight(1)
      .scrollBar(BarState.Off)
      .width(CommonConstants.FULL_PERCENT)
    }.width(CommonConstants.FULL_PERCENT)
    .height(CommonConstants.FULL_PERCENT)

    .linearGradient({
      angle: 180,
      direction: GradientDirection.Bottom, // 渐变方向
      repeating: false, // 渐变颜色是否重复
      colors: CommonConstants.colors
    })
    .padding({ top: CommonConstants.DEFAULT_STATUS_HEIGHT })

  }

  @Builder
  homeHead() {
    Column() {
      RelativeContainer() {
        Image($r('app.media.icon_home_make')).size({ width: 48, height: 45 }).id('iv_home_1')
          .alignRules({
            'top': { 'anchor': '__container__', 'align': VerticalAlign.Top },
            'left': { 'anchor': '__container__', 'align': HorizontalAlign.Start }
          })
        Image($r('app.media.icon_home_vip')).size({ width: 30, height: 30 }).id('iv_home_2')
          .alignRules({
            'top': { 'anchor': 'iv_home_1', 'align': VerticalAlign.Top },
            'end': { 'anchor': '__container__', 'align': HorizontalAlign.End },
            'bottom': { 'anchor': 'iv_home_1', 'align': VerticalAlign.Bottom }
          })

        Row() {
          Image($r('app.media.icon_home_create_music')).width('50%')
            .onClick(() => {
            })
          Column() {
            Image($r('app.media.icon_import_file')).width(CommonConstants.FULL_PERCENT)
              .onClick(() => {
              })
            Image($r('app.med
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

carden_coder

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值