While API 3.0 has a setAlpha method, most of us are still targeting 2.x since penetration for anything over 2.2 is pretty slim.

ImageViews and Drawables already have setAlpha methods, and TextViews can be manipulated using various ARGB colors. Some people just use zero-duration AlphaAnimations, so generally you can get the effect you need, but sometimes you’ll need a little more complex behavior (e.g., setting opacity based on drag position) or convenient (e.g., setting the alpha of the contents an entire layout).

Fortunately, it’s pretty simple – despite the lack of documentation.

Just extend your Layout and override onDraw, and use the canvas’s setLayerAlpha method:

Extended to support method calls: