需求:
实现一个固定宽度Row:200 ,
高度占设备总高度height: 50% ,
字体大小:14,
字体颜色(十六进制):0xc83d36 ,
背景颜色:0x8B008B,
文字:居中
实现代码:
@Entry @Component struct MyText{ // 声明写在build之前 @State message: string = '声明一个text文字' build(){ Row({space:200}){ Text(this.message) .height('50%') .fontSize(14) .fontColor(0xc83d36) .backgroundColor(0x8B008B) .align(Alignment.Center) } } }
运行结果: