1

In java with android studio I achieve this by adding this code:

webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);

webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);

webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setScrollbarFadingEnabled(false);

but I don't know how to do this in React-Native, I try some css style but nothing did the trick.

here is my webview in React:

<WebView
  ref="WebView"
  scalesPageToFit={true}
  onLoadStart={this.onLoadStart}
  onLoadEnd={this.onLoadEnd}
  source = {{ uri:this.props.navigation.getParam('main_url', 
  'https://xxxx.xxx/')}}
  style={{backgroundColor: 'transparent',width: '100%'}}
/>:null}
JonTargaryen
  • 1,317
  • 3
  • 11
  • 18

2 Answers2

2

Use user-agent.

Note: This used to only work in Android. For iOS, you could use this link Change User-Agent Now it seems to work on both iOS and android

<Webview
  userAgent="Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3714.0 Mobile Safari/537.36"
/>
Raphael Pinel
  • 2,352
  • 24
  • 26
Sanyam Jain
  • 1,154
  • 6
  • 9
0

Inspired from Sanyam's comment, you need to set user-agent for it to load as mobile:

<WebView
    userAgent={DeviceInfo.getUserAgent() + " - MYAPPNAME - android "}
    {...otherProps}
/>
romin21
  • 1,532
  • 1
  • 14
  • 35