我试图改变的WebView的文字颜色与此code
i am trying to change text color of webview with this code
String message ="<font color='white'>"+"<u>"+
"text in white"+ "<br>" +
"<font color='cyan'>"+"<font size='2'>"+
" text in blue color "+"</font>";
webview.loadData(message, "text/html", "utf8");
但我有一些HTML页面。存储在SD卡我再怎么我可以改变文字颜色。
but i have some html pages. store in my sdcard then how can i change text color..
我用
webViewRead.loadUrl(url);
URL是我的文件的路径。
url is path of my file.
您必须给像这样的文件的路径。
You have to give the path of that file like this.
String extStorageDirectory = Environment.getExternalStorageDirectory()
.toString() + "/folder_name";
File directory = new File(extStorageDirectory);
File fileInDirectory = new File(directory,file_name.html);
//Read text from file
StringBuilder html_text = new StringBuilder();
try {
BufferedReader br = new BufferedReader(new FileReader(fileInDirectory));
String line;
while ((line = br.readLine()) != null) {
html_text.append(line);
html_text.append('\n');
}
}
catch (IOException e) {
//You'll need to add proper error handling here
}
然后使用这个网站$ C $下修改
then use this html code for edit
String message ="<font color='white'>"+"<u>"+"text in white"+ "<br>" +"<font color='cyan'>"+"<font size='2'>"+" text in blue color "+"</font>";
webview.loadData(message, "text/html", "utf8");