Emi*_*l K 5 javascript reactjs react-native react-native-ios
尝试获取货币文本(52 0000,00 USD),我希望股票的字体粗细与金额不同。我希望使用 adjustmentFontSizeToFit 使文本填充整个屏幕宽度。
当使用相同的 Text 和 fontWeight 时,它可以工作,但使用嵌套<Text>比例会缩小字体大小超出必要的范围?
你可以在这里尝试一下:
https://snack.expo.io/Hk1-K3RwG
import React, { Component } from 'react';
import { Text, View, StyleSheet } from 'react-native';
import { Constants } from 'expo';
export default class App extends Component {
render() {
return (
<View style={styles.container}>
<Text style={[styles.text, {fontWeight: '900'}]} adjustsFontSizeToFit numberOfLines={1}>
{'245,000.00'}{'\u00a0'}USD
</Text>
<Text style={styles.text} adjustsFontSizeToFit numberOfLines={1}>
<Text style={{ fontWeight: '900'}}>{'245,000.00'}</Text>
{'\u00a0'}
<Text style={{ fontWeight: '400'}}>USD</Text>
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
paddingTop: Constants.statusBarHeight,
backgroundColor: '#ecf0f1',
},
text: {
height: 50,
fontSize: 60,
padding: 0,
margin: 0,
width: '100%',
textAlign: 'center',
},
});Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3175 次 |
| 最近记录: |