Button background image error on Android

This Android is so annoying.
I am developing a cross-platform dashboard view since it is not supported on Android.

So I make a button and add a background image to it. On iPhone it works normally but on Android I get SkImageDecoder::Factory returned null for each button/image.

How to solve this?

Images are in .png format. SDK

— asked 4 years ago by Dino Bartosak
  • Please share a small code snippet reflecting this, at least of how you are creating your button/image.



    — commented 4 years ago by Mauro Parra
  • @Mauro Here is the sample code:

    var image = 'images/dashboard/tasks_off.png';
    var selectedImage = 'images/dashboard/tasks_on.png';
    var button = Ti.UI.createButton({
        backgroundImage : image,
        backgroundSelectedImage : selectedImage

    As I said, this code works on iPhone, but on Android I an above error and no images are displayed.

    — commented 4 years ago by Dino Bartosak
  • If your code provided here is directly under resource folder, I mean not under subdirectory like images folder is there than the path you provided is correct other wise I think you should provide path like this,

    ~var image = '../images/dashboard/tasks_off.png';~ You can try this if you want.

    — commented 4 years ago by Yogin Bhungalia
  • @The Zero Only this thing worked: '/images/dashboard/tasks_off.png'. Tnx for the tips.

    — commented 4 years ago by Dino Bartosak

1 Answer

  • Hi Dino

    Try to specify the Height and width for the button and then try it again.



    — answered 4 years ago by Nikunj Sakhrelia
    • The trick was in the comment above. But you are right about those 2 parameters, on Android I had to set them on button initialization, not after I am placing button in view.

      — commented 4 years ago by Dino Bartosak
    • Yeah good to know that the tip from @The Zero worked which is '/images/dashboard/tasks_off.png' , I though that the height and width is missing too and so provide that solution.

      Code strong



      — commented 4 years ago by Nikunj Sakhrelia