I have a rectangular LinearLayout that has some margin, some round corners and an alpha value of 0.3. Inside this layout I have 4 different layouts as I display different im
To prevent a child view from being affected by it's parent background ...
Truth: A non-alpha-255 'color' is not actually a color - it is merely a tint!
Thus: the perceived appearance of a child view background is either:
(a) The exact color specified by child.setBackgroundColor() when that color has alpha-255 or:
(b) A composite of child.setBackgroundColor() and the parent background otherwise.
To absolutely control the child background (with utter disregard the parent) you must therefore construct a third color which will be a composite of your chosen tint and your chosen alpha-255 background.
You must nominate a background! (By definition, a tint can only be rendered against a background. If not explicitly specified the theme background will eventually come into play.)
This code took months to find and is giving perfect results.
childView.setBackgroundColor(ColorUtils.compositeColors(yourTint, yourBackground);
See my answer to my own question here.