文本样式属性
本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →
示例
- TypeScript
- JavaScript
参考
属性
color
| Type |
|---|
| color |
fontFamily
| Type |
|---|
| string |
fontSize
| Type |
|---|
| number |
fontStyle
| Type |
|---|
enum('normal', 'italic') |
fontWeight
指定字体粗细。大多数字体支持 'normal' 和 'bold' 这两个值。并非所有字体都支持所有数值选项,这种情况下会自动选择最接近的数值。
| Type | Default |
|---|---|
enum('normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900') or number | 'normal' |
includeFontPadding Android
设置为 false 可移除为某些上伸部/下伸部预留的额外内边距。部分字体中,此内边距可能导致垂直居中的文本显示偏移。为获得最佳效果,建议同时设置 textAlignVertical 为 center。
| Type | Default |
|---|---|
| bool | true |
fontVariant
支持设置字体的所有变体形式。可通过枚举数组或空格分隔的字符串设置,例如 'small-caps common-ligatures'。
| Type | Default | ||||
|---|---|---|---|---|---|
array of enum( | [] | ||||
letterSpacing
增减字符间距。默认无额外字间距。
| Type |
|---|
| number |
lineHeight
控制文本元素内行间垂直间距的数值。指定连续文本行基线之间的距离。
| Type |
|---|
| number |
textAlign
指定文本对齐方式。在 Android 上,'justify' 值仅支持 Oreo (8.0) 及以上版本(API level >= 26)。低版本 Android 会自动回退为 left。
| Type | Default |
|---|---|
enum('auto', 'left', 'right', 'center', 'justify') | 'auto' |
textAlignVertical Android
| Type | Default |
|---|---|
enum('auto', 'top', 'bottom', 'center') | 'auto' |
textDecorationColor iOS
| Type |
|---|
| color |
textDecorationLine
| Type | Default |
|---|---|
enum('none', 'underline', 'line-through', 'underline line-through') | 'none' |
textDecorationStyle iOS
| Type | Default |
|---|---|
enum('solid', 'double', 'dotted', 'dashed') | 'solid' |
textShadowColor
| Type |
|---|
| color |
textShadowOffset
| Type |
|---|
object: {width?: number, height?: number} |
textShadowRadius
| Type |
|---|
| number |
textTransform
| Type | Default |
|---|---|
enum('none', 'uppercase', 'lowercase', 'capitalize') | 'none' |
verticalAlign Android
| Type | Default |
|---|---|
enum('auto', 'top', 'bottom', 'middle') | 'auto' |
writingDirection iOS
| Type | Default |
|---|---|
enum('auto', 'ltr', 'rtl') | 'auto' |
userSelect
允许用户选择文本并使用系统原生的复制粘贴功能。此属性优先级高于 selectable 属性。
| Type | Default |
|---|---|
enum('auto', 'text', 'none', 'contain', 'all') | none |