2

I am looking for a way to load custom css into a website inside my app. Kinda like how stylish works in chrome, but then loading the css from the assets or my own website.

The website that I want to style has a horrible layout and it doesn't work at all on mobile, this is why I want to change it.

I have looked all over the internet for a solution for this problem. I came accross this solution. But that doesn't seem to work for me.

This is my current code inside OnCreate:

final String url = "http://sub.domain.com/";
    final WebView browser =(WebView) this.findViewById(R.id.browser);
    browser.getSettings().setJavaScriptEnabled(true);
    browser.setWebContentsDebuggingEnabled(true);

    String htmlData;
    htmlData = "<link rel=\"stylesheet\" type=\"text/css\" href=\"Style.css\" />";
    browser.loadDataWithBaseURL("http://www.example.com/folder/", htmlData, "text/html", "UTF-8", null);

    browser.setWebViewClient(new WebViewClient() {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            browser.loadUrl(url);
            return false;
        }
    });

I have checked element inspect in chrome, and there it displayed an about:blank with a link in the header to my custom styling. So how do I get it to display my custom styling?

Community
  • 1
  • 1

0 Answers0