将ImageBackground调整为全屏

时间:2019-04-04 19:53:59

标签: ios react-native imagebackground

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

enter image description here

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'
  }
});

2 个答案:

答案 0 :(得分:0)

确保您的源图像具有任何透明性。

width: '100%'height: '100%'设置为ImageBackground组件。它会改变什么吗?

答案 1 :(得分:0)

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