1

I have given an ImageBackground component and I want it to take the whole screen but it appears to have small paddings even if I resize twice or more the image. Where does it comes from ?

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'
  }
});
Hubert Solecki
  • 2,611
  • 5
  • 31
  • 63
  • 1
    bro, that picture is huge...... –  Apr 04 '19 at 19:56
  • 1
    Make sure your original picture fits the aspect ratio of the iOS device and then make extra sure it is 24 BPP (opaque) meaning no alpha channel in the image. – MoDJ Apr 04 '19 at 19:56
  • It seems that is the reason ! I've tried with another image and it fits perfectly ! thanks !! – Hubert Solecki Apr 04 '19 at 20:12

2 Answers2

0

Make sure your source image does not have any transparency around.

Set width: '100%' and height: '100%' to the ImageBackground component. Does it change anything?

Can Poyrazoğlu
  • 33,241
  • 48
  • 191
  • 389
0

Add width='100%' and height='100%'

Aniket G
  • 3,471
  • 1
  • 13
  • 39