Android: Lollipop (5.0) setShadowLayer()
September 10, 2016
Hi all. I’ve found something interesting with regards to using a TextView and its setShadowLayer() method.
On Android < 5.0, if you specify setShadowLayer (0, 10, 10, Color.BLACK), you would get a nice shadow that looks exactly like your text but offset by 10 on the x and y axis.
On Android 5.0 (Lollipop), it seems that this same code will produce nothing. Zip. Nada. Zilch. Zero. To make it work on this, you need to specify a non zero blur radius for the input. setShadowLayer (1, 10, 10, Color.BLACK) works just fine.
So there you go, another weird behavior of Android. I’ll look at the source code when I have time to figure out why this seems to be the case. If I got it wrong, let me know! Happy to know why.
Found a related link: https://code.google.com/p/android/issues/detail?id=7531
Note: This article was original written by me in my Wordpress blog. I’m currently trying to move all articles here.