Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

2.4K
Vistas
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 Respuestas
Responde la pregunta

0

la imagen corrige automáticamente la vista

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

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda