[AC-2169] Android: Opacity property inheritance in parent-child views
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2013-04-06T18:35:41.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | opacity, view |
Reporter | Sameeh Harfoush |
Assignee | Daniel Sefton |
Created | 2012-11-27T13:11:03.000+0000 |
Updated | 2016-03-08T07:41:09.000+0000 |
Description
*Problem description*
When having a parent-child views and the parent opacity is set, the child is inheriting the opacity value from its parent. I tried to explicitly set the opacity of the child to 1.0 but it didn't work, the property inheritance keeps taking place.
*Test case*
var window = Ti.UI.createWindow({
backgroundColor : 'white'
});
var homeView = Ti.UI.createScrollView({
width : Ti.UI.FILL,
height : Ti.UI.FILL,
backgroundColor : 'red',
scrollType : 'vertical'
});
var parent = Ti.UI.createView({
backgroundColor : 'black',
opacity : 0.8,
top : 0,
left : 0,
zIndex : 5,
visible : true,
height : 200,
touchEnabled : true
});
var child = Ti.UI.createView({
backgroundColor : '#eeeeee',
width : 100,
height : 100
});
parent.add(child);
homeView.add(parent);
window.add(homeView);
window.open();
Would it be possible to provide a simple test case for this? Thanks!
this.homeView = Ti.UI.createScrollView({ width : Ti.UI.FILL, height : Ti.UI.FILL, backgroundColor : 'red', scrollType : 'vertical' }); var parent = Ti.UI.createView({ backgroundColor : 'black', opacity : 0.8, top : 0, left : 0, zIndex : 5, visible : true, height : 200, touchEnabled : true }); var child = Ti.UI.createView({ backgroundColor : '#eeeeee', width : 100, height : 100 }); parent.add(child); this.homeView.add(parent); add this.homeView to a window or any other view you will see that "child" view background with get a redish color. thank you.
It makes sense that this occurs. Group layers in any image application (photoshop, fireworks), set the opacity on the parent, all children will and should inherit the value. If you don't want it to inherit the opacity, don't make it a child.