Android WebView: Large local image not loaded/shown
I'm trying to display a large (~> 1000x1000) image in a WebView
. The image is in the assets folder. The problem is the image doesn't get loaded, instead I see the small blue square with a question mark (presumably meaning the image could not be loaded). I made a copy of the image and resized it to ~500x500. I'm loading both the original and resized images and the resized one shows up fine.
This is the code I'm using. largeimage.jpg
is around 1500x1100 and smallimage.jpg
is the same image resized to around 500x300.
public void loadImages() {
final String mimeTy开发者_JAVA技巧pe = "text/html";
final String encoding = "utf-8";
final String html = "<img src=\"file:///android_asset/largeimage.jpg\" />" +
"<img src=\"file:///android_asset/smallimage.jpg\" />";
// webView is defined elsewhere
webView.loadDataWithBaseURL("fake://not/needed", html, mimeType, encoding, "");
}
The WebView
has the small blue box question mark followed by the small image properly loaded.
Why does this happen? Is there a resolution restriction to WebView
? Is there a file size restriction to Android? I'm fairly new to Android so I may have overlooked a simple implied limitation somewhere. If the problem is some sort of limit, can someone tell me what the maximum acceptable image size (both in resolution and file size) would be?
精彩评论