Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-13642

Android: Remove need for leading slash '/' to load images

    Details

    • Sprint:
      2018 Sprint 20 SDK

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jquick Joshua Quick
                Reporter:
                cleison.ezoom Ezoom Agency
                Reviewer:
                Gary Mathews
                Tester:
                Lokesh Choudhary
              • Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-16313
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code