How to prevent child View from inheriting its parent setAlpha value in Android

987 viewsCode SolutionssetAlpha textviewopacity

In this code solution section, I document some challenges I have faced while coding and how I was able to solve them.

The child TextView in the code below inherits alpha value from parents layout.

                android:text="Double Tap To Write Text"


There are some few hack online on how to solve this issue. But how I was able to solve it is to use the Android ColorUtils class with its method setAlphaComponent(Color.WHITE, 30);

The code snippets is show below.

int alphaColor = ColorUtils.setAlphaComponent(Color.WHITE, 30);
 TextView textView = (TextView)findViewById(;

If you have alternative solution to the above solution kindly share it with us.

Asked question