Creating a button with custom color shadow

from the CommonsWare Community archives

At September 10, 2018, 7:50am, hackzcorporation asked:

I want to create a button with custom color shadow. Is it possible to do in android?


At September 10, 2018, 11:04am, mmurphy replied:

If I had to guess, my answer is no. As on Android 5.0+ the drop shadow is supplied by the system. AFAIK, the system tries to emulate real-world shadows, and in the real world, shadows do not adopt the color of the object casting the shadow.

There is nothing stopping you from blocking the built-in shadows and baking a colorized drop shadow into the background of your button, though I do not know how you would do to that in a way that handles resizing well.

It is possible that there are other techniques that you might use, but I do not know of any.

Sorry!


At September 11, 2018, 4:47pm, mmurphy replied:

FWIW, this tweet indicates that there is a way to tint the drop shadow on Android 9.0, which also implies that it is not supported directly on older Android versions.


At September 12, 2018, 1:19pm, hackzcorporation replied:

Awesome…thanks Finally seeing some good work!