Reputation: 2281
I need to set the background of a window to be transparent programmatically, once the window is already created.
This creates a new window with a transparent background.
Titanium.UI.createWindow({url:location.href,transparentBackground:true}).open()
Background transparency can also be set in the tiapp.xml, but I need to set it after the window is loaded.
I also tried the following
var win = Titanium.UI.getCurrentWindow();
win.backgroundColor = 'transparent';
which does not have any effect...
Is there a way to achieve that?
Upvotes: 2
Views: 7267
Reputation: 341
If you want the initial window to be transparent, add this
<transparent-background>false</transparent-background>
to
<window />
on the tiapp.xml file.
Upvotes: 0
Reputation: 11
I pasted your code into a click event and it worked fine for me. All i did was change the url to 'app://index.html' for testing purposes.
$('.button').click(function(){
// test
Titanium.UI.createWindow({url:'app://index.html',transparentBackground:true}).open();
});
Have you opened the web inspector to check for js errors?
Upvotes: 0
Reputation: 5612
Perhaps you could create 2 windows with the same components, one transparent and one not. Once you want the transparent background to show close the other window?
or win.setBackgroundColor('transparent');
Upvotes: 1