1. 程式人生 > >android4.4以上 webview加在圖片的縮放問題

android4.4以上 webview加在圖片的縮放問題

 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); }