您的位置:首页 > 移动开发

android4.4以上 webview加在图片的缩放问题

2015-09-08 14:01 537 查看
if (!data.optString("content").equals("")) {
Log.d(TAG, "_______活动详情返回的图片" + data.optString("content"));
TextView nameTv = new TextView(this);
nameTv.setTextSize(16);
nameTv.setText(data.optString("name"));
WebView contentWV = new WebView(this);
//                contentWV.loadData(data.optString("content"), "text/html", "gb2312");
WebSettings webSettings= contentWV.getSettings(); // webView: 类WebView的实例
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);  //就是这句 设置布局的方式
String stingpath=data.optString("content");
String head= "<head><style>img{max-width:100%;height:auto;}</style></head>";
stingpath=head+stingpath;
//  webSettings.setBuiltInZoomControls(true);//支持缩放
// contentWV.loadDataWithBaseURL(null, data.optString("content"), "text/html", "UTF-8", null);
contentWV.loadDataWithBaseURL(null, stingpath, "text/html", "UTF-8", null);
details_ll.addView(nameTv);
details_ll.addView(contentWV);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: