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

    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>";
 
    }
发布了76 篇原创文章 · 获赞 39 · 访问量 11万+

猜你喜欢

转载自blog.csdn.net/qq_26075861/article/details/102861377
今日推荐