Android Question WebView with Assets resources

warwound

Expert
Licensed User
Longtime User
Hi, is it possible to have local js, css files e.g on my assets folder and then reference them inside my webview html source? If possible can you please provide some guidance? Thanks a lot

Yes that's possible.

You'd reference your local files using the syntax: "file:///android_asset/my_asset_name.abc" within your HTML code.
So an IMG element might look like:

PHP:
<img src="file:///android_asset/logo.png">

Martin.
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Just to add...

You can also directly reference various (built in) android drawable resources.
This is the syntax:

PHP:
<img src="file:///android_res/drawable/ic_more.png">

That'll display the built in system drawable 'ic_more'.

Martin.
 
Upvote 0
Top