Appcelerator-Q-A-banner

Button background image error on Android

You must Login before you can answer or comment on any questions.

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. 1.8.0.1 SDK

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

    Best,

    Mauro

    — commented 3 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 3 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 3 years ago by Yogin Bhungalia

  • Show 1 more comment

1 Answer

Hi Dino

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

Regards

Nikunj

— answered 3 years ago by Nikunj Sakhrelia
answer permalink
2 Comments
  • 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 3 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

    Regards

    Nikunj

    — commented 3 years ago by Nikunj Sakhrelia

Your Answer

Think you can help? Login to answer this question!