首页 > 解决方案 > 将 ImageBackground 调整为全屏

问题描述

我给了一个 ImageBackground 组件,我希望它占据整个屏幕,但即使我调整图像大小两倍或更多,它似乎也有小填充。它来自哪里?

在此处输入图像描述

Here is the code of the component

import React from "react";
import { View, Text, Button, ImageBackground, StyleSheet } from "react- 
native";

export class HomeScreen extends React.Component {

static navigationOptions = {
  //To hide the NavigationBar from current Screen
  header: null
};

render() {
  return (
     <ImageBackground source={require('../imgs/bgx.png')} style={ 
       styles.container }>
     </ImageBackground>
  );
}


}

var styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'stretch',
    resizeMode: 'stretch'
  }
});

标签: iosreact-nativeimagebackground

解决方案


添加width='100%'height='100%'


推荐阅读