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格式放置在

本文详细介绍了HarmonyOS Text组件的各种属性,包括italic、text_weight、background_element、text_alignment、multiple_lines、max_text_lines和auto_font_size,通过代码演示展示了如何设置文本的斜体、字重、背景、对齐方式、多行显示和自动调整字体大小。此外,还提及了文本自动滚动功能。
最低0.47元/天 解锁文章
835

被折叠的 条评论
为什么被折叠?



