Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

210
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda