Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webview's loaddata() not displaying the image when supply html code as String?

Webview wv=(WebView)findViewById(R.id.webview1);
``String str="<html>
            <body>
            <img src='file:///android_asset/nag.png' height='300' width='200'/>
            </body>
            </html>";
wv.loadData(str,"text/html","UTF-8");
like image 437
Nagesh N Avatar asked May 26 '26 14:05

Nagesh N


1 Answers

Try using this code

wv.loadDataWithBaseURL("file:///android_asset/", str, "text/html", "UTF-8",null);

Instead of

wv.loadData(str,"text/html","UTF-8");
like image 154
Chirag Ghori Avatar answered May 28 '26 02:05

Chirag Ghori



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!