Here's a sample app.js that shows the problem (so you don't have
to build KS):
/*global Ti, Titanium, alert, JSON */
Titanium.UI.setBackgroundColor('#000');
var win = Titanium.UI.createWindow({
title:'Test',
backgroundColor:'#fff',
fullscreen: true,
exitOnClose: true
});
var messageView = Titanium.UI.createView({
top: 0,
height:30,
width:250,
borderRadius:10,
backgroundColor:'blue',
opacity:0.7,
touchEnabled:false
});
win.add(messageView);
var v = Titanium.UI.createView({
top: 50,
height:30,
width:250,
borderRadius:10,
backgroundColor:'blue',
touchEnabled:false
});
win.add(v);
win.open();
The top view -- which sets opacity -- should look different than
the bottom view, which is otherwise the same. Because of this bug,
they look identical.
What's happening is that because a border property is being set
in addition to background, a TiBackgroundDrawable is being used.
TiBackgroundDrawable maintains its own copy of a drawable which it
draws to the canvas. It doesn't respect any of the alpha stuff
being done in TiUIHelper.setDrawableOpacity.
I can get it to work properly by...
if (drawable instanceof ColorDrawable) {
ColorDrawable colorDrawable = (ColorDrawable) drawable;
colorDrawable.setAlpha(Math.round(opacity * 255));
....
... to ...
if (drawable instanceof ColorDrawable || drawable instanceof TiBackgroundDrawable) {
drawable.setAlpha(Math.round(opacity * 255));
....
This means, however, that TiBackgroundDrawable doesn't get the
color matrix / color filter stuff -- .setColorFilter() is not
called on it. I tried overriding .setColorFilter in
TiBackgroundDrawable and passing the value to its private
'background' Drawable, but that didn't work at all. Are we sure the
color filter / color matrix thing works?
I haven't committed these changes, as I'm not strong in this
area of drawables, color filters, etc. If Don/Marshall wants me to,
I can.