简体   繁体   English

使用webview显示来自html的http图像

[英]showing http images from html using webview

i want to show the images from http not stored in local. 我想显示未存储在本地的http中的图像。 am not able to show images. 无法显示图像。

    webView = (WebView) findViewById(R.id.webView1);
    webView.getSettings().setJavaScriptEnabled(true);


    String customHtml = "<html><body>"
            + "<h1>Hello, WebView</h1>"
            +"<img src="+"'http://dreamatico.com/data_images/flowers/flowers-5.jpg'"+" height="+142+" width="+142+">"
            + "</body></html>";
    webView.loadData(customHtml, "text/html", "UTF-8");

Create the html file and put it in the assets folder and load that html file using 创建html文件并将其放在资产文件夹中,并使用加载该html文件

 WebView mWebView = null;
    mWebView = (WebView) findViewById(R.id.webview);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.loadUrl("file:///android_asset/new.html");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM