
如果想实现上面的多个文字中某些文件下面有条横线,当初我使用的是
textDecorationLine:'underline'
属性来实现文字的下划线,但是这个下划线里文字太近,不是我们想要的效果
<Text style={{fontSize:30,color:'#09b484'}}>注意方向</Text>
<Text style={{fontSize:30,color:'#fe7e57',textDecorationLine:'underline',marginRight:10}} >这是有下划线的文本</Text>
最后,我采用了一种很巧妙的方法来实现了,代码如下:
<View style={{flexDirection: 'row',alignItems:'center'}}>
<View>
<Text style={{fontSize:36,color:'#09b484'}}>注意方向</Text>
<Text style={{height:2,marginTop:10}}> </Text>
</View>
<View style={{marginRight:10}}>
<Text style={{fontSize:36,color:'#fe7e57'}} >这是有下划线的文本</Text>
<Text style={{height:2,backgroundColor:'#fe7e57',marginTop:10}} >这是有下划线的文本</Text>
</View>
</View>
上面那个空的Text是为了使所有文字上下对齐。
网友评论