buttons in android
hi,
is it possible to use images to style buttons?
like, i want an image as background - on tap i would like the image to change to a different one.
i tried to use the parameter backgroundImage and backgroundSelectedImage and image, but they don't work like expected… at least in the emulator.
like: the backgroundSelectedImage has no effecta as far as i could see. and the parameter image just changes the whole button to that image - not just uses that image as icon.
var btnLeft = Ti.UI.createButton({
backgroundImage:"/images/HouseLeft.png",
backgroundSelectedImage:"/images/HouseLeft_selected.png",
image:"/images/OneFamilyHouse.png",
width:99,
height:82
});
btnLeft.addEventListener("click", function(e){
Ti.API.info("click Left");
});
3 Answers
-
Accepted Answer
Marcin
I use android, and so I can confirm that buttons do work as expected, including on the emulator. There is a good example in the KitchenSink called button.js. Look at the code for button "b3".
So, if you run the KS > Controls > Button, and click and hold (but don't release) the big green button, you will see the subtle selected image effect. If you click it normally, it will disable the button for a specified timeout (achieved using the setTimeout() method).
Most of the functionality you require is achieved using the background*Image properties rather than the image property.
Take a look, and let me know if you have any questions about it.
-
Hi you can try this it may help u.
var MydealButt = Ti.UI.createButton({
backgroundImage:'../images/Mydealbutt.png',
backgroundSelectedImage:'../images/MyButtonselc.png',
//backgroundFocusedImage:'../images/MyButtonselc.png',
// focusable:true,
width:107ratio,
height:50ratio1,
bottom:0,
left:0*ratio,
}); -
' var MydealButt = Ti.UI.createButton({
backgroundImage:'../images/Mydealbutt.png',
backgroundSelectedImage:'../images/MyButtonselc.png',
//backgroundFocusedImage:'../images/MyButtonselc.png',
// focusable:true,
width:107ratio,
height:50ratio1,
bottom:0,
left:0*ratio,
});
'