Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android AppCompat 21 Elevation

Is there any way to add elevation to a View in pre-lollipop devices without wrapping them in a CardView?

like image 506
Eliezer Avatar asked Nov 04 '14 05:11

Eliezer


1 Answers

ViewCompat.setElevation(View, int) currently creates no shims.

The only way to simulate elevation right now is to apply a shadow pre-v21. Define your style/layout/drawable in values and override it in values-v21. For buttons I use style overrides. For layouts, I usually go for reference override (use @null to get rid of a drawable).

Hopefully in the future an update to the support library will add shims.

This reddit thread keeps track of said update.

Edit

The new support design library actually does create shims for the floating action button.

like image 69
Derk-Jan Avatar answered Sep 22 '22 01:09

Derk-Jan