add shadow to layout programmatically in Android?



So I have many LinearLayouts and RelativeLayouts that I need to apply shadows to. But all these layouts will have different background color.


For example, I have 3 LinearLayouts. I need one Blue, One Green and One Red but all will have the same shadows and style (except for the color).


I already have these layouts created so what can I do to apply shadows to them manually?


If I create an XML drawable then I have to create a different drawable for each color. Is there any other way I can do this?


I was thinking about making a common function where I can pass either a LinearLayout or RelativeLayout and apply the shadow effects with a specific solid color as background.


But I am not sure if there is a way to apply shadow programmatically. Please let me know what my choices are.


Thank you for your time.


No comments:

Post a Comment