react-native - react native Flex : 1 Does not fill whole screen

标签 react-native flexbox

我尝试使用 flex: 1 用黑色填充整个屏幕。但结果是这样的

resuls in iphone simulator

result in my android devices

  <View
    style={{
      flex: 1,
      backgroundColor: 'black',
    }}
  />

我也尝试过使用:

   height: '100%',
   width: '100%',

const HEIGHT = Dimensions.get('window').height;
const WIDTH = Dimensions.get('window').width;

但结果还是一样。

有没有办法完全填满整个屏幕?

最佳答案

您是否将应用程序包装在安全区域 View 内,无论如何,如果 flex:1 不起作用,您可以使用百分比宽度和高度来填充整个屏幕。

style = {{ width:'100%', height:'100%' }}

关于react-native - react native Flex : 1 Does not fill whole screen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60500654/

相关文章:

react-native - 在React-Native中使用自定义字体

css - 如何在 React Native 中绘制半椭圆?

html - 样式化具有两列的表单

html - 如何在 flexbox 容器中放置两个 <div>?

javascript - VSCode如何禁用/删除 "react/cjs/react.development"自动完成

javascript - set.State 未定义

html - 在 flex 容器中将搜索字段居中,同时将 Logo 保持在右侧?

html - 左上对齐按钮文本

css - 将最后一个 flex 元素放在容器的末尾

ios - RN能通过苹果应用商店审核吗?