private void getHtml_data(String Url, int FontSize) {
String text = "";
try {
URL url = new URL(Url);
URLConnection conn;
conn = url.openConnection();
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn
.getInputStream()));
String line = "";
String data = "";
while ((line = rd.readLine()) != null) {
Message lmsg;
lmsg = new Message();
lmsg.obj = line;
lmsg.what = 0;
data = data + (String) lmsg.obj;
}
text = data.replace("<body>", "<body style=\"font-size:" + FontSize
+ "px;\">");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
myWebView.loadDataWithBaseURL("", text, "text/html", "UTF-8", null);
}
data就是你要的网页源码,text修改(就像我在body 加上size)
最后用myWebView.loadDataWithBaseURL("", text, "text/html", "UTF-8", null);