旋转视图会消失它的一些内容
giving rotation to a View disappears some of its content
我的屏幕上有 10 个使用这种样式的视图:
<View style={{
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#005b96',
}}>
<Text style={{
fontSize: 20,
fontWeight: '600',
color: '#eee',
}}>{number}</Text>
</View>
这就是我得到的
但是当我将 transform:[{rotate: '5deg'}]
添加到 View
的样式时,除 1 之外的所有数字都消失了!
似乎旋转缩小了其内容的空间,因此文本消失了,但由于 1 足够精简,所以仍然像以前一样!
我尝试为 Text
提供额外的宽度和高度,但它没有用!
将此样式添加到 Text
的样式中就成功了!
width: '100%',
textAlign: 'center',
backgroundColor: 'black', // gave the background so the effect will be obvious.
得到这个:
我的屏幕上有 10 个使用这种样式的视图:
<View style={{
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#005b96',
}}>
<Text style={{
fontSize: 20,
fontWeight: '600',
color: '#eee',
}}>{number}</Text>
</View>
这就是我得到的 transform:[{rotate: '5deg'}]
添加到 View
的样式时,除 1 之外的所有数字都消失了! Text
提供额外的宽度和高度,但它没有用!
将此样式添加到 Text
的样式中就成功了!
width: '100%',
textAlign: 'center',
backgroundColor: 'black', // gave the background so the effect will be obvious.
得到这个: