webView加载富文本,内容适配屏幕

mac2025-10-08  1

webView.loadDataWithBaseURL(null,setWebVIewImage(message), "text/html", "UTF-8", null); // 适配image和table标签 public static String setWebVIewImage(String star) { String head = "<head>" + "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\"> " + "<style>img{max-width: 100%; width:auto; height:auto;}</style>" + "<style>table{max-width: 100%; width:auto; height:auto;}</style>" + "</head>"; return "<html>" + head + "<body>" + star + "</body></html>"; }

 

最新回复(0)