且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

机器人的WebView链接颜色

更新时间:2023-11-18 23:39:28

好吧,我设法做到这一点,并希望分享我的方式为未来的访客。

Okay, I managed to do it and wanted to share my way for the future visitors.

首先,我创建了所需的样式,名为css文件的style.css ,根据资产的文件夹保存

First I created a css file with the desired style, named style.css, saved under assets folder

a {color:purple; text-decoration:none}

那么,在code我加载页面,如下所示,其中内容是页面的实际HTML内容

Then, in the code I loaded the page as follows where content is the actual html content of the page

String htmlBody = "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" />" + content;
mWebView.loadDataWithBaseURL("file:///android_asset/", htmlBody, "text/html", "utf-8",
            null);

这就是它!希望它可以帮助别人。

That's it! Hope it helps somebody.