Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

521
Visualizações
Set phone background image using React Native

I'm new to React, I managed to upload an image from the local phone gallery and store its URI in a global variable, but I can't find anywhere how to set the image to my phone background image (not in react!). The end goal is to allow a change by date in the background. Assuming I can use global.frstImgURI, and global.secImgURI and global.thrdImgURI as my images path (by import). How can I achieve that?

Currently, I manage to upload an image, then show it in my react native, BG, but not on my phone. My current code for choosing image:

import React from 'react';
import {View, ImageBackground, StyleSheet, Dimensions} from 'react-native';
import global from '../components/global'

const screenHeight = Dimensions.get('window').height;
const screenWidth = Dimensions.get('window').width;

const BackgroundImg = () => {
    return <View>
                <ImageBackground
                    source={{uri: global.day1_image }}
                    resizeMode="stretch"
                    style={styles.img}>
                </ImageBackground>
            </View>
};
export default BackgroundImg;
const styles = StyleSheet.create({
    img: {
        height: screenHeight,
        width: screenWidth,
        justifyContent: 'center',
        alignItems: 'center',
    }
})

Show it on React BG:

import * as React from 'react';
import { View } from 'react-native';
import BackgroundImg from '../components/Background_image'
const App = () => {
    return (
        <View>
            <BackgroundImg />
        </View>
    );
};
export default App;

My thought is using a dynamic list, and changing images by if statement connected to time (still didn't implement), but as said, I can't find how to change the phone image BG at all. Thanks!

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

In the case , import image with their extension , then direct pass ImageBackground

import global from '../assets/global.png'

const screenHeight = Dimensions.get('window').height;
const screenWidth = Dimensions.get('window').width;

const BackgroundImg = () => {
    return <View>
                <ImageBackground
                    source={global}
                    resizeMode="stretch"
                    style={styles.img}>
                </ImageBackground>
            </View>
};
about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda