Why is my image (and child components) not showing with ImageBackground on React Native?

Why is my image (and child components) not showing with ImageBackground on React Native?



I am having an issue with the image just showing up on the application. Through search results, I mostly see the solution being that that the height and width was required and missing, but I have already implemented with no results.



I have looked at the routes multiple times and don't see any issues on that end.



Lastly, I thought it could be something to do with the image. I have altered the size and it worked with the <Image /> tag. However, I need it to be a background image.


<Image />


import React from 'react'
import View, Text, StyleSheet, ImageBackground from 'react-native';
import MaterialCommunityIcons from '@expo/vector-icons'

export default function TitleScreen ()

return (
<View>
<ImageBackground
source=require('../assets/images/title_background.png')
style=styles.backgroundImage
imageStyle=resizeMode: 'cover'
>
<Text>testing</Text>
/* <MaterialCommunityIcons
name='cards-outline'
size=100
/> */
</ImageBackground>
</View>
)


const styles = StyleSheet.create(
backgroundImage:
flex: 1,
width: '100%',
height: '100%',

);






Try adding flex: 1 to view

– Pritish Vaidya
Sep 10 '18 at 21:55


flex: 1


view






Oh my goodness, that did it. Thank you! The examples shown didn't show that so I missed it. Appreciate it!

– Alize Nguyen
Sep 10 '18 at 21:58




1 Answer
1



Answered! The answer was to add flex: 1 to the parent view container - for those running into the same problem.



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế