#鸿蒙学习大百科#如何实现子组件均匀分配父容器主轴方向的剩余空间?

如何实现子组件均匀分配父容器主轴方向的剩余空间?

HarmonyOS
2024-09-25 10:38:32
1565浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
超级马里奥64
@Entry
@Component
struct Index {
  list: string[] = ["a", "b", "c", "d", "e"]
  build() {
    Column() {
      Row() {
        ForEach(this.list, (item: string) => {
          Text(item)
            .width(50)
            .height(50)
            .fontColor(Color.White)
            .textAlign(TextAlign.Center)
            .backgroundColor(Color.Blue)
        })
      }.justifyContent(FlexAlign.SpaceEvenly)//均匀分配主轴方向的子内容
      .width("100%")

    }
    .height('100%')
    .width('100%')
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.

分享
微博
QQ
微信
回复
2024-09-25 15:28:59


相关问题
#鸿蒙学习大百科#如何实现ui优化?
1023浏览 • 1回复 待解决