image - Android Webview load local content with picture resize -
i have got html content interface , show in webview,but pics large , small,how should make big pics fits screen , keep small pics' size? here script :
if (android.os.build.version.sdk_int >= 19) { // 设置图片自适应(4.4以上安卓版本) document doc_dis = jsoup.parse(content); elements ele_img = doc_dis.getelementsbytag("img"); if (ele_img.size() != 0) { for (element e_img : ele_img) { //if(e_img.) e_img.attr("style", "width:100%"); } } string newhtmlcontent = doc_dis.tostring(); webview.loaddatawithbaseurl( com.sns.cangmin.sociax.api.api.gethost(), newhtmlcontent, "text/html", "utf-8", null); } else { // 设置图片自适应(不适合4.4以上安卓版本) websetting.setlayoutalgorithm(layoutalgorithm.single_column); websetting.setbuiltinzoomcontrols(true); // 设置显示缩放按钮 websetting.setsupportzoom(true); // 支持缩放 webview.loaddatawithbaseurl( com.sns.cangmin.sociax.api.api.gethost(), content, "text/html", "utf-8", null); }
but small pics resize screen width in 4.4.4 , how should it??
Comments
Post a Comment