Milan Nankov

Milan Nankov

Code Bites: Label Shadows for NativeScript on Android

Shadows allow us to put emphasis on parts of application UI. Once such example is having a button with more pronounced text. 

Here is a comparison of some buttons with and without shadows.

Label shadows

The first line sticks out a lot more due to the applied shadows. So how can shadow be added to a text in when using NativeScript. The key is the Label component of NativeScript. Under the hood, Label uses an instance of the native TextView view that allows us to set shadows with its setShadowLayer method.

Here is how to do it:

You can find the complete source code on Github at https://github.com/milannankov/nativescript-label-shadows .

Happy coding.

Need consulting on this topic?

Yes No

Thank You! We will be in touch.