Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2929] Webview image source parity between iOS an Android

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2012-08-20T10:35:47.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterNeville Dastur
AssigneeShak Hossain
Created2012-07-01T11:30:23.000+0000
Updated2016-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()

Comments

  1. Anirudh Nagesh 2012-07-03

    Just 'img_path = img.png' works fine for both Android and iOS. Please test it with latest mobile SDK. Regards, Anirudh
  2. Shak Hossain 2013-12-27

    Closing this since this issue can't be reproduced and the reporter has not got back to us since filing the issue.

JSON Source