Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setElevation( ) for LinearLayout before 5.0 devices

Hi I'm trying to apply a shadow to a linearlayout with the following code

if (<some condition>) layout.setElevation(4);

but this call requires API level 21 to work. How can I apply a shadow to layouts for devices with version < 5.0? Is it possible?

I know this is part of Material Design which is why I just want to know if there is a way to achieve something similar in previous versions, thanks :)

like image 959
Mallika Khullar Avatar asked Jan 17 '26 23:01

Mallika Khullar


1 Answers

Use ViewCompat.setElevation(view, elevation);

like image 135
Evgeni Roitburg Avatar answered Jan 20 '26 11:01

Evgeni Roitburg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!