(本机反应)如何将SafeAreaView用于Android陷波设备? [英] (React native) How to use SafeAreaView for Android notch devices?

查看:660
本文介绍了(本机反应)如何将SafeAreaView用于Android陷波设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上正在开发一个具有本机反应的应用程序,并且我正在测试我的plus 6. SafeAreaView是iPhone X的解决方案,但对于Android,似乎没有解决方案.

I'm actually developing an app with react native and i'm testing with my one plus 6 and it has a notch. The SafeAreaView is a solution for the iPhone X but for Android, it seems there is no solution.

有人听说过有什么方法可以解决这个问题吗?

Did someone heard about anything to solve this kinf of issue ?

推荐答案

最近必须使用的解决方法:

A work around I had to use recently:

GlobalStyles.js:

GlobalStyles.js:

import { StyleSheet, Platform } from 'react-native';
export default StyleSheet.create({
    droidSafeArea: {
        flex: 1,
        backgroundColor: npLBlue,
        paddingTop: Platform.OS === 'android' ? 25 : 0
    },
});

它的用法如下:

App.js

import GlobalStyles from './GlobalStyles';
import { SafeAreaView } from "react-native";

render() {
    return (
      <SafeAreaView style={GlobalStyles.droidSafeArea}>
          //More controls and such
      </SafeAreaView>
    );
  }
}

您可能需要对其进行一些调整以适合您正在使用的任何屏幕,但这使我的标题位于顶部图标栏的下方.

You'll probably need to adjust it a bit to fit whatever screen you're working on, but this got my header just below the icon strip at the top.

这篇关于(本机反应)如何将SafeAreaView用于Android陷波设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆