【发布时间】:2020-12-29 00:39:25
【问题描述】:
我使用的是 react native 0.63.4,我使用 <View style={{flex: 1}}> 作为每个页面的根元素。
我使用Dimensions.get("screen").width 使元素具有响应性。由于某种原因,屏幕宽度的值不正确,而是一个更大的值。因此屏幕上的每个元素都会变大。
预期行为:
Expected image.
问题:issue image
我已经用许多设备进行了测试。我只在 Galaxy S20 Ultra 和 S10 Lite 上看到这个问题。安装 Android 11 和 OneUi 3.0 更新后出现此问题。
代码:
const {height: screen_height, width: screen_width} = Dimensions.get('screen');
<View style={{ flex: 1,justifyContent:"center",alignItems:"center" }}>
<Text style={{fontSize:screen_width/15}}>text</Text>
</View>;
什么可能导致问题?
更新:仅当设备的屏幕分辨率设置为 3200x1440 时才会出现此问题。该应用在较低分辨率下可以正常工作。
【问题讨论】:
-
你能添加你的代码吗?没有它很难帮助你。
标签: react-native