首先,先摆一个需要load的html代码
<span style="color: rgb(51, 51, 51); font-family: 'PingFang SC', 'Lantinghei SC', 'Microsoft YaHei', arial, 宋体, sans-serif, tahoma; font-size: 16px; white-space: pre-wrap;">病情分析:皮肤病的发生与人的健康情况,生活习惯,工作环境与身心状况等都有密切关系.</span>
<pre accuse="aContent" class="best-text mb-10" id="best-content-1464550588" style="margin-top: 10px; margin-bottom: 10px; padding: 0px; font-family: 'PingFang SC', 'Lantinghei SC', 'Microsoft YaHei', arial, 宋体, sans-serif, tahoma; white-space: pre-wrap; word-wrap: break-word; font-size: 16px; line-height: 29px; color: rgb(51, 51, 51); min-height: 55px;">
(1)健康情况 有些皮肤病是由于全身<a class="baidu-highlight" href="https://www.baidu.com/s?wd=%E6%80%A7%E7%96%BE%E7%97%85&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvnHw-PW0YnHwbujcsPyfL0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnjR3PWfd" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">性疾病</a>引起的,如<a class="baidu-highlight" href="https://www.baidu.com/s?wd=%E5%85%A8%E8%BA%AB%E6%80%A7%E7%BA%A2%E6%96%91%E7%8B%BC%E7%96%AE&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvnHw-PW0YnHwbujcsPyfL0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnjR3PWfd" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">全身性红斑狼疮</a>,或由于慢性病引起的,如糖尿病,<a class="baidu-highlight" href="https://www.baidu.com/s?wd=%E8%82%BA%E7%BB%93%E6%A0%B8&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvnHw-PW0YnHwbujcsPyfL0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnjR3PWfd" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">肺结核</a>,梅毒等;有些皮肤病与免疫障碍或接受免疫抑制治疗有关,这种病人由于抵抗力低,较易发生带状疱疹,脱发,座疮等.
(2)接触过敏源 经常容易引起皮肤病变的过敏源有植物类如毒性长青藤,橡树,漆树等;还有花粉,食物,化妆品,清洗剂等.
(3)皮肤疹也有可能是由于使用如维生素,轻泻剂,抗生素,碘胺类药物引起.
(4)有些皮肤病与遗传有关,如<a class="baidu-highlight" href="https://www.baidu.com/s?wd=%E7%89%9B%E7%9A%AE%E7%99%A3&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvnHw-PW0YnHwbujcsPyfL0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnjR3PWfd" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">牛皮癣</a>,<a class="baidu-highlight" href="https://www.baidu.com/s?wd=%E5%AF%BB%E5%B8%B8%E6%80%A7%E7%97%A4%E7%96%AE&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvnHw-PW0YnHwbujcsPyfL0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnjR3PWfd" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">寻常性痤疮</a>,白斑,<a class="baidu-highlight" href="https://www.baidu.com/s?wd=%E5%BC%82%E4%BD%8D%E6%80%A7%E7%9A%AE%E7%82%8E&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvnHw-PW0YnHwbujcsPyfL0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnjR3PWfd" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">异位性皮炎</a>,<a class="baidu-highlight" href="https://www.baidu.com/s?wd=%E9%B1%BC%E9%B3%9E%E7%99%A3&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvnHw-PW0YnHwbujcsPyfL0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnjR3PWfd" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">鱼鳞癣</a>,单纯性水疱性肯皮溶解症,先天性手掌足迹<a class="baidu-highlight" href="https://www.baidu.com/s?wd=%E8%A7%92%E5%8C%96%E7%97%87&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvnHw-PW0YnHwbujcsPyfL0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnjR3PWfd" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">角化症</a>和秃发等多有遗传性,其中<a class="baidu-highlight" href="https://www.baidu.com/s?wd=%E5%BC%82%E4%BD%8D%E6%80%A7%E7%9A%AE%E7%82%8E&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvnHw-PW0YnHwbujcsPyfL0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnjR3PWfd" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">异位性皮炎</a>更有一定家庭史.
(5)与职业有关的皮肤病多见于因接触化学物质而致的疾病,如氯化物痤疮,麦粉湿疹以及与屠宰业有关的急性传染病如炭疽,<a class="baidu-highlight" href="https://www.baidu.com/s?wd=%E9%A9%AC%E9%BC%BB%E7%96%BD&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvnHw-PW0YnHwbujcsPyfL0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnjR3PWfd" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">马鼻疽</a>等.
(6)有些皮肤病多发生于某特定地区,如皮肤爬行疹多流行于热带.
(7)长期生活在拥挤,不洁环境的人易患衣虱病,常与有头虱,<a class="baidu-highlight" href="https://www.baidu.com/s?wd=%E9%98%B4%E8%99%B1&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvnHw-PW0YnHwbujcsPyfL0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnjR3PWfd" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">阴虱</a>和夜里疮的人密切接触,易受传染.
(8)长时间在寒冷或酷热的天气下从事户外活动,常会引起皮肤症状.
意见建议:要想预防皮肤病,就要搞清楚皮肤病发生的原因及其发展后果,根据不同情况加以防范.主要措施有以下几个方面:
(1)保持皮肤的清洁卫生 对油性皮肤要经常用肥皂和温水清洗;对干性皮肤则应少用肥皂.
(2)保持皮肤弹性 在寒冷季节,要经常用润肤剂涂于皮肤,保持皮肤的弹性和柔软,减少皮肤皲裂.
(3)保持头皮 头皮有保护头皮免受外界刺激的作用,应注意经常修剪,定期洗头,保持头皮的清洁.
(4)清洁指甲 指甲要经常修剪,并清除甲前端下的污物.
(5)保护皮肤 即使是皮肤有细小的破损,也要及时处理;对已有感染的皮肤要在注意清洁的基础上注意保护,适当进行隔离,防止接触感染;对瘙痒性皮肤在积极治疗的基础上要防止因抓挠引起继发感染;暑天,痱子是皮肤感染的先兆,因此,防痱,治痱至关重要.
(6)消除与饮食有关的诱因 对某些皮肤病如湿疹,银屑病,荨麻疹,酒渣鼻,脂溢性皮炎等,应注意限制食用鱼,虾等海腥食物和辛辣性食物.
同时,增强体质,保持精神愉快,注意锻炼,合理营养,提高机体免疫力,改善健康大辩论况等也是非常重要的.</pre>
在android4.4之前,这样的写法是可以让内容适应屏幕大小的;
String content = "上边的内容";
WebSettings settings = webView.getSettings();
// 自适应屏幕
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
settings.setJavaScriptEnabled(true);
// 设置可以支持缩放
// settings.setSupportZoom(true);
// 设置出现缩放工具
// settings.setBuiltInZoomControls(true);
webView.loadDataWithBaseURL(null, content, "text/html", "utf-8", null);
但是在4.4之后,(如果html里面本身并没有去做适配移动设备的话),宽度可能会超出屏幕宽度,并且有横向的滚动条;
在网上找了各种方法,但是都没有比较合适的解决方案,setUseWideViewPort和setLoadWithOverviewMode,还有setLayoutAlgorithm方法虽然是被提到最多的,可是在4.4之后,光这样设置确实是没有效果的;
经过漫长的探索以及实验,发现5.0之后,webview是会自动适应屏幕的,settengs什么都不需要设置,内容不会超过屏幕宽,但是会很挤,字体小而且高度算不上自适应(和5.0之前,调用 webView.setWebChromeClient(new WebChromeClient());的效果一样);本想着这样然后去settings.setDefaultFontSize(size);设置字体大小,但是....无效(确实没明白为什么无效???)
再次经过漫长的探索,最终找到了<meta>标签;自己添加一个meta标签
常用写法<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
WebSettings settings = webView.getSettings();
// 自适应屏幕
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
//扩大比例的缩放
settings.setJavaScriptEnabled(true);
// 设置可以支持缩放
// settings.setSupportZoom(true);
// int size = Utils.dip2px(ArticleDetailActivity.this, 50);
// settings.setDefaultFontSize(size);
// 设置出现缩放工具
// settings.setBuiltInZoomControls(true);
String css = "<style type=\"text/css\"> </style>";
String html = "<html><header><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no>"+css+"</header>"+"<body>"+content+"</body>"+"</html>";
webView.loadDataWithBaseURL(null, html, "text/html", "utf-8", null);
但是需要注意,Android4.0以下手机不支持viewport的width,需要设置target-densitydpi;