Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13642] Android: Remove need for leading slash '/' to load images

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2018-10-02T18:44:46.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.5.0
ComponentsAndroid
Labelsandroid, image, parity
ReporterEzoom Agency
AssigneeJoshua Quick
Created2013-04-22T13:43:21.000+0000
Updated2018-10-02T18:45:03.000+0000

Description

*Summary:* The image and backgroundImage properties require a leading slash '/' on Android when loading an image file from the "Resources" directory or else it will fail to load. iOS and Windows do not require the leading slash, although they will accept it too. Android should be changed to be consistent with iOS and Windows. For example, if you have an image file in the following location in a Classic app... ./Resources/assets/images/Test.png On Android, you have to load the above image file like this...
var imageView = Ti.UI.createImageView({
	image: "/images/Test.png",
});
On iOS and Windows, you can load the image with or without the leading slash...
var imageView = Ti.UI.createImageView({
	image: "images/Test.png",  // This works.
//	image: "/images/Test.png",  // This also works.
});
Changing Android to support both would make it less confusing for developers who work on the iOS side first. *Note:* This is not an issue when loading files via Ti.Filesystem.getFile(). Accessing files via a relative path works in this case. This is an issue with accessing files via relative paths (ie: no leading slash). ---- *Original Bug Report:* As can be seen here (http://developer.appcelerator.com/question/148590/alloy-android-not-getting-images) to load images on android using alloy we need to use a forward slash \(/\) before the image name, I know it's not a big work for us, but we don't need it using default appcelerator.

Comments

  1. Ezoom Agency 2013-04-24

    actually I mean remove "/images/" because when we build for iOS we use "image.png" but for android we need "/images/image.png" which is really boring
  2. Joshua Quick 2018-09-01

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/10304
  3. Lokesh Choudhary 2018-09-14

    FR Passed.
  4. Christopher Williams 2018-10-02

    Closing as well since FR and CR passed.

JSON Source