how to load android assets css files to android WebView URL

后端 未结 2 603
感动是毒
感动是毒 2021-01-12 12:38

Actually I want to load complete site from internet link but i want to load css files from mobile (means not from internet). Because I want to load all page faster using int

2条回答
  •  余生分开走
    2021-01-12 13:17

    Please put CSS in assets folder, and refer to CSS by relative path, and load HTML to WebView by loadDataWithBaseURL() method: if your css file name is mycss.css

    StringBuilder data = new StringBuilder();
    data .append("");
    data .append(tables.toString());
    data .append("");
    webView.loadDataWithBaseURL("file:///android_asset/", data .toString(), "text/html", "utf-8", null);
    

    thank you

提交回复
热议问题