[TIMOB-13642] Android: Remove need for leading slash '/' to load images
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-10-02T18:44:46.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 7.5.0 |
Components | Android |
Labels | android, image, parity |
Reporter | Ezoom Agency |
Assignee | Joshua Quick |
Created | 2013-04-22T13:43:21.000+0000 |
Updated | 2018-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.
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
PR (master): https://github.com/appcelerator/titanium_mobile/pull/10304
FR Passed.
Closing as well since FR and CR passed.