Chintan Mehta
Chintan Mehta

Reputation: 117

Why is the image not showing in android app in webview?

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!

Upvotes: 0

Views: 2358

Answers (2)

Saikrishna Rajaraman
Saikrishna Rajaraman

Reputation: 3273

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.

Upvotes: 1

Jaimin Sarvan
Jaimin Sarvan

Reputation: 142

Try to below code

web_object.loadDataWithBaseURL("file:///android_res/drawable/", "<img src='test.jpg' />", "text/html", "utf-8", null);

Upvotes: 0

Related Questions