0

The html code is as follows for the image :

<img src="file:///res/drawable/jobs.jpg" style="margin-left:1em; height:300px; width:300px; border-radius:50%;">

The image is located in the "drawable folder" and this html document is in the "assets" folder. The directory structure is such : App->src->main->assets; and App->src->main->res->drawable

Android - local image in webview In this link, they say that put the image file in assets folder then it would load, but if i do that, an error pops up saying that this folder can only hold .xml files.

I also tried ../drawable/jobs.jpg but that didnt work too

Even tried ../../drawable/jobs.jpg, no luck there too.

Can someone help me out here really stuck!

Chintan Mehta
  • 129
  • 1
  • 9

2 Answers2

1

Try this.

<img src="file:///android_asset/jobs.jpg" style="margin-left:1em; height:300px; width:300px; border-radius:50%;">

Put your image file in app->src->main->assets

Have your html page in the assets folder as well.

Saikrishna Rajaraman
  • 3,205
  • 2
  • 16
  • 29
0

Try to below code

web_object.loadDataWithBaseURL("file:///android_res/drawable/", "<img src='test.jpg' />", "text/html", "utf-8", null);
  • The problem with this is that I have 5 other images that i need to load in the same html file, so if there's a way to do that then this can be a viable option – Chintan Mehta Mar 20 '18 at 14:39