鸿蒙要实现如图效果,代码简洁到令人难以置信:
整体布局是水平方向的,用row容器,左边是Image加载图标,中间是Text。右边也是Image加载图片,主轴子组件之间的距离用justifyContent(FlexAlign.SpaceBetween),代码如下:
@Entry @Component struct IndexTest {@State message: string = 'IndexTest';build() {Column(){Row(){Image($r('app.media.ic_arrow_left')).width(40).height(60)Text('个人中心').fontSize(25)Image($r('app.media.foreground')).width(40).height(60)}.justifyContent(FlexAlign.SpaceBetween).height(60).backgroundColor(Color.Pink).width('100%').padding({right:10,left:10})}.width('100%').height('100%').backgroundColor('#ccc')// .justifyContent(FlexAlign.SpaceBetween)} }