Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebView in Android not showing web page styles

I am trying to make an Android app display a website in a WebView, but only the website home page actually show content properly via the WebView, the other pages completely disregard the website styles and display content with a white background and blue default hyperlinks. I tested the same type of app on iOS and it works fine there. What can I do about it?

Android version

enter image description here

This is the method:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    WebView myWebView = (WebView) findViewById(R.id.webView);
    myWebView.getSettings().setJavaScriptEnabled(true);
    myWebView.setWebViewClient(new WebViewClient());
    myWebView.loadUrl("http://www.awesomestories.com");
}
like image 952
jotun Avatar asked Oct 24 '25 21:10

jotun


1 Answers

Settings should be set.
Tricks Like this:

    WebSettings settings = webview.getSettings();
    settings.setBuiltInZoomControls(true);
    settings.setPluginState(PluginState.ON);
    settings.setJavaScriptEnabled(true);
    settings.setSupportZoom(true);
like image 117
SilentKnight Avatar answered Oct 27 '25 12:10

SilentKnight