[AC-2929] Webview image source parity between iOS an Android
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2012-08-20T10:35:47.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | n/a |
Reporter | Neville Dastur |
Assignee | Shak Hossain |
Created | 2012-07-01T11:30:23.000+0000 |
Updated | 2016-03-08T07:47:54.000+0000 |
Description
On iOS the filepath for local asserts is relative to / but on Android the file:///android_asset/Resource prefix is required. Note that file:/// alone does not work.
If there is no fix then please document.
Is suspect the default baseurl needs to be set for android
var win = Ti.UI.createWindow({title: 'Title'});
var webview = Ti.UI.createWebView({
borderRadius : 4,
width : '100%', height : '100%',
top : 0,
backgroundColor:'white',
scalesPageToFit:true,
touchEnabled: true,
});
// Webview don't know about retina displays so fix with conditional
var img_path = (Ti.Platform.displayCaps.dpi <300) ? '/img2x.png' : '/img.png';
if(_platform==='android') img_path = 'file:///android_asset/Resources' + img_path;
webview.html = '<html><body><img src="' + img_path + '" /></body></html>';
win.add(webview);
win.open()
Just 'img_path = img.png' works fine for both Android and iOS. Please test it with latest mobile SDK. Regards, Anirudh
Closing this since this issue can't be reproduced and the reporter has not got back to us since filing the issue.