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); }
android4.4以上 webview加在图片的缩放问题
最新推荐文章于 2022-07-06 16:28:10 发布