HarmonyOS 已经设置长度100%,为什么页面显示还是不到100%

import { Home } from '../pages/tabs/Home'
import { Mine } from '../pages/tabs/Mine'
import { Shop } from '../pages/tabs/Shop'
import { VideoTab } from '../pages/tabs/VideoTab'

@Entry
@Component
struct MainPage {
  @State currentIndex: number = 0
  @State Build: Array<TextObj> = [
    {
      text: '首页',
      num: 0,
      imageYes: $r('app.media.home_yes'),
      imageNo: $r('app.media.home_no')
    },
    {
      text: '视频',
      num: 1,
      imageYes: $r('app.media.home_yes'),
      imageNo: $r('app.media.video_home_icn')
    },
    {
      text: '商城',
      num: 2,
      imageYes: $r('app.media.shop_yes'),
      imageNo: $r('app.media.shop_no')
    },
    {
      text: '我的',
      num: 3,
      imageYes: $r('app.media.user_yes'),
      imageNo: $r('app.media.user_no')
    },

  ]

  @Builder
  NavigationTitle() {
    Column() {
      Text('Title')
        .fontColor('#182431')
        .fontSize(20)
        .lineHeight(41)
        .fontWeight(300)
    }.alignItems(HorizontalAlign.Start)
  }

  @Builder
  NavigationMenus() {
    Row() {
      if (this.currentIndex == 0) {
        Image($r('app.media.home_no'))
          .width(24)
          .height(24)
          .margin({ left: 24 })
      } else if (this.currentIndex == 1) {
        Image($r('app.media.home_no'))
          .width(24)
          .height(24)
          .margin({ left: 24 })
      } else if (this.currentIndex == 2) {
        Image($r('app.media.home_no'))
          .width(24)
          .height(24)
          .margin({ left: 24 })
      } else if (this.currentIndex == 3) {
        Image($r('app.media.home_no'))
          .width(24)
          .height(24)
          .margin({ left: 24 })
      } else {
        Image($r('app.media.home_no'))
          .width(24)
          .height(24)
          .margin({ left: 24 })
      }
    }
  }

  @Builder
  show() {
    if (this.currentIndex == 0) {
      Home();
    } else if (this.currentIndex == 1) {
      VideoTab();
    } else if (this.currentIndex == 2) {
      Shop();
    } else if (this.currentIndex == 3) {
      Mine();
    } else {
      Home();
    }
  }

  @Builder
  NavigationToolbar() {


    Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceAround }) {
      ForEach(this.Build, (item: TextObj) => {
        Column() {
          Image(this.currentIndex == item.num ? item.imageYes : item.imageNo)
            .width(24)
            .height(24)
          Text(item.text)
            .fontColor(this.currentIndex == item.num ? '#007DFF' : '#182431')
            .fontSize(10)
            .lineHeight(14)
            .fontWeight(500)
            .margin({ top: 3 })
        }.height(56)
        .onClick(() => {
          this.currentIndex = item.num
        })
      })

    }
  }

  build() {
    Column() {
      Navigation() {
        this.show();
      }
      .toolbarConfiguration(this.NavigationToolbar)
      .hideToolBar(false)
      .onTitleModeChange((titleModel: NavigationTitleMode) => {
        console.info('titleMode' + titleModel)
      })
    }.width('100%').height('100%').backgroundColor(Color.Blue) //.backgroundColor('#F1F3F5')
  }
}

class TextObj {
  text: string = '';
  num: number = 0;
  imageYes: Resource = $r('app.media.home_yes');
  imageNo: Resource = $r('app.media.home_no');
}
HarmonyOS
1天前
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
Heiang

需要给Navigation组件加一个属性hideTitleBar(true)。

分享
微博
QQ
微信
回复
1天前
相关问题
HarmonyOS 子控件设置宽度100%问题
28浏览 • 1回复 待解决
HarmonyOS 宽度100%,左右间距不生效
40浏览 • 1回复 待解决
HarmonyOS 宽度100% margin左右不生效
97浏览 • 1回复 待解决
hi3860v100语言模块代码报错
1204浏览 • 0回复 待解决