Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2169] Android: Opacity property inheritance in parent-child views

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2013-04-06T18:35:41.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsopacity, view
ReporterSameeh Harfoush
AssigneeDaniel Sefton
Created2012-11-27T13:11:03.000+0000
Updated2016-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();

Comments

  1. Daniel Sefton 2012-11-27

    Would it be possible to provide a simple test case for this? Thanks!
  2. Sameeh Harfoush 2012-11-28

    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.
  3. Daniel Sefton 2013-04-06

    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.

JSON Source