HarmonyOS(鸿蒙)——Text(文本)组件介绍

本文详细介绍了HarmonyOS Text组件的各种属性,包括italic、text_weight、background_element、text_alignment、multiple_lines、max_text_lines和auto_font_size,通过代码演示展示了如何设置文本的斜体、字重、背景、对齐方式、多行显示和自动调整字体大小。此外,还提及了文本自动滚动功能。
摘要由CSDN通过智能技术生成

ohos:height=“match_content”

ohos:width=“match_content”

ohos:text=“李子捌”

ohos:text_size=“100px”

ohos:text_color=“#000000”

ohos:text_font=“HwChinese-medium”

/>

演示效果:

在这里插入图片描述

2.5 italic

| 属性名称 | 中文描述 | 取值 | 取值说明 | 使用案例 |

| — | — | — | — | — |

| italic | 文本是否斜体字体 | boolean类型 | 可以直接设置true/false,也可以引用boolean资源。 | ohos:italic=“true"ohos:italic=”$boolean:true" |

代码演示:

<Text

ohos:id=“$+id:text”

ohos:height=“match_content”

ohos:width=“match_content”

ohos:text=“李子捌”

ohos:text_size=“100px”

ohos:text_color=“#000000”

ohos:text_font=“sans-serif”

ohos:italic=“true”

/>

演示效果:

在这里插入图片描述

2.6 text_weight

| 属性名称 | 中文描述 | 取值 | 取值说明 | 使用案例 |

| — | — | — | — | — |

| text_weight | 字重 | integer类型 | 表示字体大小的integer类型。也可以引用integer资源。 | ohos:text_weight=“100"ohos:text_weight=”$integer:100" |

代码演示:

<Text

ohos:id=“$+id:text”

ohos:height=“match_content”

ohos:width=“match_content”

ohos:text=“Liziba”

ohos:text_size=“100px”

ohos:text_color=“#0000FF”

ohos:text_font=“serif”

ohos:italic=“true”

ohos:text_weight=“100”

/>

演示效果:

text_weight = 100

在这里插入图片描述

text_weight = 600

在这里插入图片描述

2.7 background_element

常用的背景如常见的文本背景、按钮背景,可以采用XML格式放置在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值