赞
踩
金樽清酒斗十千,玉盘珍羞直万钱。 停杯投箸不能食,拔剑四顾心茫然。 欲渡黄河冰塞川,将登太行雪满山。 闲来垂钓碧溪上,忽复乘舟梦日边。 行路难,行路难,多歧路,今安在? 长风破浪会有时,直挂云帆济沧海。
目录
- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("袁震")
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }
- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("袁震")
- .fontSize(30)
- .fontColor("#22aaff")
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("袁震")
- .fontStyle(FontStyle.Italic)//斜体
- .fontSize(30)
- .fontColor("#22aaff")
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("袁震")
- .fontWeight(FontWeight.Bold)//加粗
- .fontSize(30)
- .fontColor("#22aaff")
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

也可以通过设置数值调整加粗程度,取值为100-900
900效果为:
- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("袁震")
- .fontWeight(900)//加粗
- .fontSize(30)
- .fontColor("#22aaff")
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("袁震")
- .fontWeight(900)//加粗
- .fontSize(30)
- .fontColor("#22aaff")
- .width(200) //宽度
- .height(200) //高度
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("袁震")
- .fontWeight(900)//加粗
- .fontSize(30)
- .fontColor("#22aaff")
- .width(200) //宽度
- .height(200) //高度
- .backgroundColor("#ccaabb") //背景色
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("袁震")
- .fontWeight(900)//加粗
- .fontSize(30)
- .fontColor("#22aaff")
- .width(200) //宽度
- .height(200) //高度
- .backgroundColor("#ccaabb") //背景色
- .textAlign(TextAlign.Center)//文字水平居中
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("袁震")
- .fontWeight(900)//加粗
- .fontSize(30)
- .fontColor("#22aaff")
- .width(200) //宽度
- .height(200) //高度
- .backgroundColor("#ccaabb") //背景色
- .textAlign(TextAlign.Center)//文字水平居中
- .borderRadius(10) //背景圆角
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("袁震")
- .fontWeight(900)//加粗
- .fontSize(30)
- .fontColor("#22aaff")
- .width(200) //宽度
- .height(100) //高度
- .backgroundColor("#ccaabb") //背景色
- .textAlign(TextAlign.Center)//文字水平居中
- .borderRadius(10) //背景圆角
- .border({width: 2, color: '#000000'}) //添加边线
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("英雄联盟德玛西亚之力")
- .fontWeight(900)//加粗
- .fontSize(30)
- .fontColor("#22aaff")
- .width(200) //宽度
- .height(100) //高度
- .backgroundColor("#ccaabb") //背景色
- .textAlign(TextAlign.Center)//文字水平居中
- .borderRadius(10) //背景圆角
- .maxLines(1) //最大显示一行
- .border({width: 2, color: '#000000'}) //边框
- .textOverflow({overflow: TextOverflow.None}) //超长文字截断
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("英雄联盟德玛西亚之力")
- .fontWeight(900)//加粗
- .fontSize(30)
- .fontColor("#22aaff")
- .width(200) //宽度
- .height(100) //高度
- .backgroundColor("#ccaabb") //背景色
- .textAlign(TextAlign.Center)//文字水平居中
- .borderRadius(10) //背景圆角
- .maxLines(1) //最大显示一行
- .border({width: 2, color: '#000000'}) //边框
- .textOverflow({overflow: TextOverflow.Ellipsis}) //超长显示省略号
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("英雄联盟德玛西亚之力")
- .fontWeight(900)//加粗
- .fontSize(30)
- .fontColor("#22aaff")
- .width(200) //宽度
- .height(100) //高度
- .backgroundColor("#ccaabb") //背景色
- .textAlign(TextAlign.Center)//文字水平居中
- .borderRadius(10) //背景圆角
- .maxLines(1) //最大显示一行
- .border({width: 2, color: '#000000'}) //边框
- .textOverflow({overflow: TextOverflow.MARQUEE}) //超长滚动
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("英雄联盟德玛西亚之力")
- .fontWeight(900)//加粗
- .fontSize(30)
- .fontColor("#22aaff")
- .width(200) //宽度
- .height(200) //高度
- .backgroundColor("#ccaabb") //背景色
- .textAlign(TextAlign.Center)//文字水平居中
- .borderRadius(10) //背景圆角
- .border({width: 2, color: '#000000'}) //边框
- .lineHeight(60) //行高
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("英雄联盟德玛西亚之力")
- .fontWeight(900)//加粗
- .fontSize(30)
- .fontColor("#22aaff")
- .width(200) //宽度
- .height(200) //高度
- .backgroundColor("#ccaabb") //背景色
- .textAlign(TextAlign.Center)//文字水平居中
- .borderRadius(10) //背景圆角
- .border({width: 2, color: '#000000'}) //边框
- .lineHeight(60) //行高
- .letterSpacing(20) //字间距
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

注意:需要minFontSize ,maxFontSize,maxline 以及文本框大小配合使用
- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("英雄联盟德玛西亚之力")
- .fontWeight(900)//加粗
- .fontSize(30)
- .fontColor("#22aaff")
- .width(200) //宽度
- .height(200) //高度
- .backgroundColor("#ccaabb") //背景色
- .textAlign(TextAlign.Center)//文字水平居中
- .borderRadius(10) //背景圆角
- .border({width: 2, color: '#000000'}) //边框
- .lineHeight(60) //行高
- .minFontSize(15) //最小字体15
- .maxFontSize(30) //最大字体30
- .maxLines(1) //最多显示一行
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("abcd")
- .fontWeight(900)//加粗
- .textCase(TextCase.UpperCase) //字母大写
- .fontSize(30)
- .fontColor("#22aaff")
- .width(200) //宽度
- .height(200) //高度
- .backgroundColor("#ccaabb") //背景色
- .textAlign(TextAlign.Center)//文字水平居中
- .borderRadius(10) //背景圆角
- .border({width: 2, color: '#000000'}) //边框
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("ABCD")
- .fontWeight(900)//加粗
- .textCase(TextCase.LowerCase) //字母小写
- .fontSize(30)
- .fontColor("#22aaff")
- .width(200) //宽度
- .height(200) //高度
- .backgroundColor("#ccaabb") //背景色
- .textAlign(TextAlign.Center)//文字水平居中
- .borderRadius(10) //背景圆角
- .border({width: 2, color: '#000000'}) //边框
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("ABcd")
- .fontWeight(900)//加粗
- .textCase(TextCase.Normal) //字母正常显示
- .fontSize(30)
- .fontColor("#22aaff")
- .width(200) //宽度
- .height(200) //高度
- .backgroundColor("#ccaabb") //背景色
- .textAlign(TextAlign.Center)//文字水平居中
- .borderRadius(10) //背景圆角
- .border({width: 2, color: '#000000'}) //边框
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("ABcdefghfsenfkbkbfgkgldfkledmsam")
- .fontWeight(900)//加粗
- .textCase(TextCase.Normal) //字母正常显示
- .fontSize(30)
- .fontColor("#22aaff")
- .width(200) //宽度
- .height(200) //高度
- .backgroundColor("#ccaabb") //背景色
- .borderRadius(10) //背景圆角
- .border({width: 2, color: '#000000'}) //边框
- .textIndent(10)//设置首行文本缩进
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

- @Entry
- @Component
- struct TestPage {
-
- build() {
- RelativeContainer() {
- Text("ABcdefghfsenfkbkbfgkgldfkledmsam"){
- Span("我是子组件1")
- .fontSize(20)
- .fontColor("#000000")
- .fontWeight(900)//加粗
- Span("我是子组件2")
- .fontSize(15)
- .fontColor("#ffffff")
- Span("我是3")
- .fontSize(20)
- .fontColor("#ffccdd")
- }
- .width(300) //宽度
- .height(100) //高度
- .backgroundColor("#ccaabb") //背景色
- .borderRadius(10) //背景圆角
- .border({width: 2, color: '#000000'}) //边框
- .alignRules({
- top: { anchor: '__container__', align: VerticalAlign.Center },
- middle: { anchor: '__container__', align: HorizontalAlign.Center }
- })
- .id('txt1')
- }
- }
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。