web视图中的android如何设置文本颜色 [英] how set text color of webview in android

查看:81
本文介绍了web视图中的android如何设置文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图改变的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"); 

这篇关于web视图中的android如何设置文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆