鸿蒙-布局子组件宽度均匀分布且不受子组件文字个数影响
·
效果:

//设置复用样式
@Extend(Text) function style(){
.fontWeight(700)
.height("100%")
.flexGrow(1) //平分剩余空间
.width(0) //关键:重置默认宽度,避免字体撑开
.textAlign(TextAlign.Center) //字体居中
.border({ width: { right: 1 }, color: Color.Gray })
}
布局:
Row() {
Text("聊天")
.style()
Text("朋友圈")
.style()
Text("个人中心")
.style()
}.width("100%").height("10%")
更多推荐

所有评论(0)