Why do child views inherit the alpha value from parent layout Why do child views inherit the alpha value from parent layout android android

Why do child views inherit the alpha value from parent layout


That is exactly how it is intended to work.

Why not simply change the alpha of your background drawable "@drawable/bg" to 0.2?

Alternatively, try a FrameLayout with this basic structure:

<FrameLayout>    <ImageView        android:background="@drawable/bg"         android:alpha="0.2" />    <LinearLayout>        <Button />        <Button />    </LinearLayout>     </FrameLayout>


One way is to set the alpha value within the hash-code for color i.e. instead of #RRGGBB use #AARRGGBB. This makes sure that the alpha value isn't inherited.


You will need to use a framelayout. other wise your button is enlosed by a linearlayout with aplha set which will also affect the buttons.