Changing text color in a WebView?

后端 未结 8 575
梦如初夏
梦如初夏 2020-12-17 09:06

There\'s a method for altering background color but not font.
Any ideas?

8条回答
  •  清歌不尽
    2020-12-17 09:40

    You can concatenate your answer one body tag HTML with CSS style hex color, this is an example using a JSON response

    First: function for decode JSON to HTML format

    public String stripHtml(String html) {
        return Html.fromHtml(html).toString();
    }
    

    Second: Load data in WebView (no url)

     String string_html;
     string_html = "<body style="color:#535362;">" + youStringHTML + "</body>";
     webView.loadDataWithBaseURL(null, stripHtml(string_html), "text/html", "utf-8", null);
    

提交回复
热议问题