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

2.4K
Visualizações
Cambio de tamaño de imagen en React Native

Estoy tratando de cambiar el tamaño de una imagen (más pequeña para ajustarse a la pantalla) en mi aplicación nativa de reacción, pero no puedo hacerlo porque es demasiado grande.

Aquí está el código:

 'use strict'; var React = require('react-native'); var { StyleSheet, Text, TextInput, View, TouchableHighlight, ActivityIndicatorIOS, Image, Component } = React; var styles = StyleSheet.create({ description: { marginBottom: 20, fontSize: 18, textAlign: 'center', color: '#656565' }, container: { padding: 30, marginTop: 65, alignItems: 'center' }, flowRight: { flexDirection: 'row', alignItems: 'center', alignSelf: 'stretch' }, buttonText: { fontSize: 18, color: 'white', alignSelf: 'center' }, button: { height: 36, flex: 1, flexDirection: 'row', backgroundColor: '#48BBEC', borderColor: '#48BBEC', borderWidth: 1, borderRadius: 8, marginBottom: 10, alignSelf: 'stretch', justifyContent: 'center' }, searchInput: { height: 36, padding: 4, marginRight: 5, flex: 4, fontSize: 18, borderWidth: 1, borderColor: '#48BBEC', borderRadius: 8, color: '#48BBEC' }, image: { width: 200, height: 220 }, }); class SearchPage extends Component { render() { return ( <View style={styles.container}> <Image source={require('image!rclogo')} style={styles.image}/> <Text style={styles.description}> Search for RCers! </Text> <Text style={styles.description}> Search </Text> <View style={styles.flowRight}> <TextInput style={styles.searchInput} placeholder='Search by Batch, Name, Interest...'/> <TouchableHighlight style={styles.button} underlayColor='#99d9f4'> <Text style={styles.buttonText}>Go</Text> </TouchableHighlight> </View> <TouchableHighlight style={styles.button} underlayColor='#99d9f4'> <Text style={styles.buttonText}>Location</Text> </TouchableHighlight> </View> ); } }

Traté de sacarlo de la etiqueta del contenedor, pero parece que no puedo entender por qué no se representa correctamente.

¿Se puede hacer esto con flexbox resizeMode? ¿Cómo lo haces? No puedo encontrar ningún documento al respecto ...

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

la imagen corrige automáticamente la vista

 image: { flex: 1, width: null, height: null, resizeMode: 'contain' }
over 4 years ago · Santiago Trujillo Relatório

0

Ajusto un poco tu respuesta (shixukai)

 image: { flex: 1, width: 50, height: 50, resizeMode: 'contain' }

Cuando lo configuro en nulo, la imagen no se mostrará en absoluto. Me puse en cierto tamaño como 50

over 4 years ago · Santiago Trujillo Relatório

0

Esto funcionó para mí:

 image: { flex: 1, aspectRatio: 1.5, resizeMode: 'contain', }

la relación de aspecto es solo ancho/alto (mi imagen tiene 45 px de ancho x 30 px de alto).

over 4 years ago · Santiago Trujillo 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