| text_size | 文本大小 | float类型 | 表示字体大小的float类型。可以是浮点数值,其默认单位为px;也可以是带px/vp/fp单位的浮点数值;也可以引用float资源。 | ohos:text_size=“30"ohos:text_size=“16fp"ohos:text_size=”$float:size_value” |
代码演示:
<Text
ohos:id=“$+id:text”
ohos:height=“match_content”
ohos:width=“match_content”
ohos:text=“150px”
ohos:text_size=“150px”/>
显示效果:
2.3 text_color
| 属性名称 | 中文描述 | 取值 | 取值说明 | 使用案例 |
| — | — | — | — | — |
| text_color | 文本颜色 | color类型 | 可以直接设置色值,也可以引用color资源。 | ohos:text_color=“#A8FFFFFF"ohos:text_color=”$color:black" |
代码演示:
<Text
ohos:id=“$+id:text”
ohos:height=“match_content”
ohos:width=“match_content”
ohos:text=“blue”
ohos:text_size=“100px”
ohos:text_color=“blue”
/>
演示效果:
使用HEX效果:
2.4 text_font
| 属性名称 | 中文描述 | 取值 | 取值说明 | 使用案例 |
| — | — | — | — | — |
| text_font | 字体 | sans-serif | 可以设置的字体如表中所列。 | ohos:text_font=“HwChinese-medium” |
| | | sans-serif-medium | | |