Quantcast
Channel: Active questions tagged flexbox - Stack Overflow
Viewing all articles
Browse latest Browse all 1305

How to position image in ImageBackground component?

$
0
0

I just want to place this image to the top of the screen with ImageBackground component of React Native, using this background image resizeMode='contain' (NOT cover) since the image is fit to dimensions now I need to place it on top.

Found some solution like here:- https://stackoverflow.com/a/55674160/21163479

But it doesn't seems to be working.

Here is my code:-

import { Text, SafeAreaView, ImageBackground } from 'react-native'import React from 'react'const Login = () => {  return (<SafeAreaView style={[{flex: 1}]}><ImageBackground        source={require('../assets/img/auth-bg.jpg')}        resizeMode='contain'        style={[{          flex: 1,          justifyContent: 'flex-start',          backgroundColor: 'pink'        }]}        imageStyle={[{ resizeMode: 'contain', alignSelf: 'flex-start' }]}><Text>--CONTENT HERE--</Text></ImageBackground></SafeAreaView>  )}export default Login

And here how it looks:-

imagebackground resize mode contain to position the image on top of the screen


Viewing all articles
Browse latest Browse all 1305

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>