首先,先擺一個需要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;">病情分析:皮膚病的發(fā)生與人的健康情況,生活習慣,工作環(huán)境與身心狀況等都有密切關(guān)系.</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" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">性疾病</a>引起的,如<a class="baidu-highlight" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">全身性紅斑狼瘡</a>,或由于慢性病引起的,如糖尿病,<a class="baidu-highlight" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">肺結(jié)核</a>,梅毒等;有些皮膚病與免疫障礙或接受免疫抑制治療有關(guān),這種病人由于抵抗力低,較易發(fā)生帶狀皰疹,脫發(fā),座瘡等.
(2)接觸過敏源 經(jīng)常容易引起皮膚病變的過敏源有植物類如毒性長青藤,橡樹,漆樹等毫痕;還有花粉,食物,化妝品,清洗劑等.
(3)皮膚疹也有可能是由于使用如維生素,輕瀉劑,抗生素,碘胺類藥物引起.
(4)有些皮膚病與遺傳有關(guān),如<a class="baidu-highlight" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">牛皮癬</a>,<a class="baidu-highlight" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">尋常性痤瘡</a>,白斑,<a class="baidu-highlight" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">異位性皮炎</a>,<a class="baidu-highlight" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">魚鱗癬</a>,單純性水皰性肯皮溶解癥,先天性手掌足跡<a class="baidu-highlight" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">角化癥</a>和禿發(fā)等多有遺傳性,其中<a class="baidu-highlight" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">異位性皮炎</a>更有一定家庭史.
(5)與職業(yè)有關(guān)的皮膚病多見于因接觸化學(xué)物質(zhì)而致的疾病,如氯化物痤瘡,麥粉濕疹以及與屠宰業(yè)有關(guān)的急性傳染病如炭疽,<a class="baidu-highlight" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">馬鼻疽</a>等.
(6)有些皮膚病多發(fā)生于某特定地區(qū),如皮膚爬行疹多流行于熱帶.
(7)長期生活在擁擠,不潔環(huán)境的人易患衣虱病,常與有頭虱,<a class="baidu-highlight" style="color: rgb(63, 136, 191); text-decoration: none;" target="_blank">陰虱</a>和夜里瘡的人密切接觸,易受傳染.
(8)長時間在寒冷或酷熱的天氣下從事戶外活動,常會引起皮膚癥狀.
意見建議:要想預(yù)防皮膚病,就要搞清楚皮膚病發(fā)生的原因及其發(fā)展后果,根據(jù)不同情況加以防范.主要措施有以下幾個方面:
(1)保持皮膚的清潔衛(wèi)生 對油性皮膚要經(jīng)常用肥皂和溫水清洗贼穆;對干性皮膚則應(yīng)少用肥皂.
(2)保持皮膚彈性 在寒冷季節(jié),要經(jīng)常用潤膚劑涂于皮膚,保持皮膚的彈性和柔軟,減少皮膚皸裂.
(3)保持頭皮 頭皮有保護頭皮免受外界刺激的作用,應(yīng)注意經(jīng)常修剪,定期洗頭,保持頭皮的清潔.
(4)清潔指甲 指甲要經(jīng)常修剪,并清除甲前端下的污物.
(5)保護皮膚 即使是皮膚有細小的破損,也要及時處理憨颠;對已有感染的皮膚要在注意清潔的基礎(chǔ)上注意保護,適當進行隔離,防止接觸感染绿满;對瘙癢性皮膚在積極治療的基礎(chǔ)上要防止因抓撓引起繼發(fā)感染蹂楣;暑天,痱子是皮膚感染的先兆,因此,防痱,治痱至關(guān)重要.
(6)消除與飲食有關(guān)的誘因 對某些皮膚病如濕疹,銀屑病,蕁麻疹,酒渣鼻,脂溢性皮炎等,應(yīng)注意限制食用魚,蝦等海腥食物和辛辣性食物.
同時,增強體質(zhì),保持精神愉快,注意鍛煉,合理營養(yǎng),提高機體免疫力,改善健康大辯論況等也是非常重要的.</pre>
在android4.4之前,這樣的寫法是可以讓內(nèi)容適應(yīng)屏幕大小的;
String content = "上邊的內(nèi)容";
WebSettings settings = webView.getSettings();
// 自適應(yīng)屏幕
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
settings.setJavaScriptEnabled(true);
// 設(shè)置可以支持縮放
// settings.setSupportZoom(true);
// 設(shè)置出現(xiàn)縮放工具
// settings.setBuiltInZoomControls(true);
webView.loadDataWithBaseURL(null, content, "text/html", "utf-8", null);
但是在4.4之后,(如果html里面本身并沒有去做適配移動設(shè)備的話),寬度可能會超出屏幕寬度,并且有橫向的滾動條;
在網(wǎng)上找了各種方法,但是都沒有比較合適的解決方案,setUseWideViewPort和setLoadWithOverviewMode,還有setLayoutAlgorithm方法雖然是被提到最多的,可是在4.4之后,光這樣設(shè)置確實是沒有效果的;
經(jīng)過漫長的探索以及實驗,發(fā)現(xiàn)5.0之后,webview是會自動適應(yīng)屏幕的,settengs什么都不需要設(shè)置,內(nèi)容不會超過屏幕寬,但是會很擠,字體小而且高度算不上自適應(yīng)(和5.0之前,調(diào)用 webView.setWebChromeClient(new WebChromeClient());的效果一樣);本想著這樣然后去settings.setDefaultFontSize(size);設(shè)置字體大小,但是....無效(確實沒明白為什么無效???)
再次經(jīng)過漫長的探索,最終找到了<meta>標簽;自己添加一個meta標簽
常用寫法<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
WebSettings settings = webView.getSettings();
// 自適應(yīng)屏幕
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
//擴大比例的縮放
settings.setJavaScriptEnabled(true);
// 設(shè)置可以支持縮放
// settings.setSupportZoom(true);
// int size = Utils.dip2px(ArticleDetailActivity.this, 50);
// settings.setDefaultFontSize(size);
// 設(shè)置出現(xiàn)縮放工具
// 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唉工,需要設(shè)置target-densitydpi;