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

127
Views
¿Cómo mantener el texto en la misma posición mientras anima su tamaño de fuente? reaccionar nativo

Estoy trabajando en Text Scaling en el que quiero escalar el texto pero manteniendo la posición x. Ahora, estoy escalando el texto pero pierde su posición actual. ¿Puede alguien ayudarme con eso?

 <Animated.View style={{ transform: [{ translateY: transText }] }}> <Animated.View onLayout={({ nativeEvent: { layout: { width, height } } }) => { label.current = { width, height }; }} style={{ width: width - (width / 3), transform: [{ scale: textScale }, { translateX: labelTransX }, { translateY: labelTransY }], justifyContent: 'flex-end' }}> <TouchableWithoutFeedback onPress={handleMenu}> <View style={{ flexDirection: 'row', alignItems: 'center' }}> <View> <Animated.Text style={{ color: isDarkMode ? colors.TextBodyL : 'black', fontSize: 28, fontWeight: 'bold' }} numberOfLines={1}> {mainLabel} </Animated.Text> </View> <Animated.View style={{ transform: [{ rotate: rotate.interpolate({ inputRange: [0, 180], outputRange: ['0deg', '180deg'], extrapolate: 'extend' }) }] }}> <Icon name={'caret-down-outline'} size={20} color={isDarkMode ? colors.TextBodyL : 'black'} /> </Animated.View> </View> </TouchableWithoutFeedback> </Animated.View> <Animated.View style={{ transform: [{ translateY: labelTransY }] }}> <Text style={{ color: isDarkMode ? colors.TextBodyL : colors.TextBodyD }}> {notesState.length} notes </Text> </Animated.View> </Animated.View>

Este código anterior de alguna manera mantiene el texto para mantener su posición pero no demasiado preciso.

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

0

Hay un par de opciones.

  1. Fácil: Pon tu texto en un contenedor con justifyContent: 'center', alignItems: 'center'

  2. Más molesto: agregue marginTop y marginLeft negativos a sus propiedades de texto animado, pero multiplique esa cantidad por el cambio en fontSize , multiplicado por PixelRatio/fontScale.

Esperemos que la primera opción te funcione; si no, avíseme si necesita más información sobre el segundo.

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!