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

211
Vistas
React native webview font size change makes text propagate outside

im building a summary view where i import text from and uri inside a webview ad i inject js to change size but when i do that the text go outside the webview.

This is how the uri loads into the webview:

This is how the uri loads into the webview

and this is what i get when i change the font-size:

enter image description here

this is the webview :

  <WebView 
    key={this.state.value}
    ref={webview => this.setState({WebViewRef:webview})}
    javaScriptEnabled={true}
    domStorageEnabled={true}
    scalesPageToFit={false}
    onLoadEnd={
      this.setState({
        visibleBack:false
      })
    }
    automaticallyAdjustContentInsets={false}
    source={{ uri: `http://backend.iferu.com/cleanbook.php?idbook=${this.props.product.id}` }} style={{paddingLeft:15,height:this.state.webViewHeight ,width: Dimensions.get('window').width - 50}}
    key={this.state.key}
    injectedJavaScript={jsBeforeLoad}
    onMessage={this.onMessage}
    scrollEnabled={false}
    style={{ height : this.state.webViewHeight}}    
/>

and this is the js im injecting to change font-size:

sendDataToWebView(){
    let injectedData =
    `
      // document.getElementsByTagName("body")[0].style.fontSize = '${this.state.fontSizeState}px';
      $('#takeAways').css({
        'font-size':${this.state.fontSizeState},
      });
      $('#recomClass').css({
        'font-size':${this.state.fontSizeState}
      });
      $('#summaryTitle').css({
        'font-size':${this.state.fontSizeState}
      });
      $('#summaryText').css({
        'font-size':${this.state.fontSizeState}
      });
      $('#auteurTitle').css({
        'font-size':${this.state.fontSizeState}
      });
      $('#auteurText').css({
        'font-size':${this.state.fontSizeState}
      });
      window.ReactNativeWebView.postMessage(Math.max(document.body.offsetHeight, document.body.scrollHeight));  
    `;
    this.state.WebViewRef.injectJavaScript(injectedData);
  }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It only happens on Android(I'm working on the opposite, actually, to webview font size increase on iOS)

But if you want to lock the font size, you can use textZoom prop.

https://github.com/react-native-webview/react-native-webview/blob/master/docs/Reference.md#textZoom

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