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

232
Vistas
React Native - text gets truncated too much

I have the following component

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>
    );
}

When I reference it from another component and I set the width of wrapper component below a certain value the text is truncated too much leaving a big gap.

<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>

The code above with width at 40% produces the below Width at 40%

When I set width at 50% or greater the text is truncated how I want it Width at 50%

What I want is:

yellow background to stretch to the end of the red container at all width

Please note if the label length is not long enough to be truncated the yellow color should only wrap text and not stretch to end of red container

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

Expected result with short label Expected short label

Expected result with long label Expected long label

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Did you try to use it with flex ? I would try to give flex:1.

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can either add flex: 1 or width:"100%" to the text ..


edit:

in InputLabel.tsx remove flexDirection: row and alignItems: center from Animated View

about 4 years ago · Juan Pablo Isaza 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