Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
React Native: el texto se trunca demasiado

tengo el siguiente componente

 const InputLabel => (props: InputLabelProps) { return ( <Animated.View style={[ StyleSheet.absoluteFill, { justifyContent: 'flex-start', flexDirection: 'row', backgroundColor: 'red', alignItems: 'center', }, ]} > <Animated.Text onLayout={onLayoutAnimatedText} numberOfLines={1} ellipsizeMode="tail" textBreakStrategy={'highQuality'} style={[ animatedLabelContainerStyle, { textAlign: 'right', fontSize: fontSize, color: labelColor, backgroundColor: 'yellow', }, ]} > {label} </Animated.Text> </Animated.View> ); }

Cuando hago referencia a él desde otro componente y configuro el ancho del componente contenedor por debajo de cierto valor, el texto se trunca demasiado dejando un gran espacio.

 <View style={{ width: '40%', height: 50, borderWidth: 1, backgroundColor: 'yellow' }}> <InputLabel fontSize={16} hasOutline={false} label={'label 12345678901234567890123456789012345678901234567890'} // labelAnimatedValue={labelAnimation} labelColor={'black'} labelLayout={labelLayout} OffsetY={2} //container borderWidth placeholderColor={'red'} showPlaceholder={false} onLayoutAnimatedText={handleLayoutAnimatedText} /> </View>

El código anterior con ancho al 40% produce el siguiente ancho al 40%

Cuando configuro el ancho al 50% o más, el texto se trunca como lo quiero Ancho al 50%

lo que quiero es:

fondo amarillo para estirar hasta el final del contenedor rojo en todo el ancho

Tenga en cuenta que si la longitud de la etiqueta no es lo suficientemente larga como para truncarla, el color amarillo solo debe envolver el texto y no extenderse hasta el final del contenedor rojo.

Merienda: https://snack.expo.dev/@danro/inputlabel

Resultado esperado con etiqueta corta Etiqueta corta esperada

Resultado esperado con etiqueta larga Etiqueta larga esperada

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

¿Intentaste usarlo con flex ? Intentaría dar flex:1 .

about 4 years ago · Juan Pablo Isaza Report

0

Puede agregar flex: 1 o ancho: "100%" al texto.


editar :

en InputLabel.tsx elimine flexDirection: fila y alignItems: centro de la vista animada

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!