Search code examples
javaandroidviewdrawableandroid-drawable

Android - transparent GradientDrawable turns gray on emulator


transparent turns graytransparent turns gray

I am using GradientDrawable for decoration.

The transparent is correct on the real devices, but it turns gray on some emulators (It seems to be correct after a certain system version).

my code like

... new GradientDrawable()
        .setCornerRadius(...)
        .setColors(...) //set multiple colors with transparent here
        .setOrientation(...)
...

Does anyone know how to solve it? Thanks.


Solution

  • Are You using the default "@android:color/transparent"? the solution is on the hex code, sometimes the default is a "black transparent": #00000000, this cause the gradient going gray.

    Try to manually set the transparent to white: #00FFFFFF, this should solve your problem