Button Transparency
Anyone know how to make a button WITH and image obey the alpha channel stuff for transparency?
I thought this would work, but it doesn't. If I load sample.png into Photoshop, you can see the transparency layer is in fact there. I am placing my button over an ImageView, but the button transparency layer is showing up white rather than with the imageView behind.
var btnTest = Titanium.UI.createButton({
image:'sample.png',
left:10,
top:10,
backgroundColor:'transparent'
});
2 Answers
-
Accepted Answer
Instead of setting the image try loading the image into backgroundImage and define the height and width. I am using code like this and it honors that transparency in the PNG.
var btnTest = Ti.UI.createButton({ backgroundImage: 'sample.png', height: 24, width: 20, top: 10, left:10 });
-
var btnTest = Titanium.UI.createButton({ image:'sample.png', left:10, top:10, opacity:0.1 // 0.0 - 1.0 });