[英]How to fix Empty Space on top of Curved Android Phone
我的 react-native 应用在我在模拟器上测试的大多数 Android 设备(和 iOS)上看起来都很好,但是一些顶部有明显弯曲屏幕的设备(Google Pixel 4,API 29),它在手机顶部显示了一个很大的空白区域.
这看起来不正常。 你知道如何解决吗?
我正在使用
SafeAreaView<\/code>但没有任何 Android 特定的填充\/边距。
<SafeAreaView style={{flex:1}}>
... My App Code come here.
</SafeAreaView>
你有没有试过用这种方式
<StatusBar translucent={true} hidden={true} /> {/* <--- Here */}
检查状态栏组件,您可以使用名为translucent
的属性在状态栏下方绘制应用程序。 参考链接
您可以通过像这样隐藏您的StatusBar
来实现这一点:
import React from "react";
import { StatusBar, View, Text } from "react-native";
export default class Main extends React.Component {
constructor(props) {
super(props);
}
componentDidMount() {
StatusBar.setHidden(true);
}
render() {
return (
<View style={{ flex: 1, backgroundColor: 'white' }}>
<Text> Hello World, How to fix this ? </Text>
</View>
);
}
}
更新:将StatusBar
的transluent
属性设置为 true 并使其背景transparent
如下所示:
import React, { Component } from "react";
import { StatusBar, View, Text } from "react-native";
export default class Main extends Component {
constructor(props) {
super(props);
}
componentDidMount() {
StatusBar.setTranslucent(true);
StatusBar.setBackgroundColor("transparent");
}
render() {
return (
<View style={{ flex: 1, backgroundColor: 'white' }}>
<Text> Hello World, How to fix this ? </Text>
</View>
);
}
}
我设法通过转到 AVD 管理器来解决此问题 -> 单击擦除数据
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.