4

I am trying the apply elevation effect for ImageButton. It works well on my Nexus tablet running Android 5.0 but elevation does not work on Pre-Lollipop devices.

Tried ViewCompat.setElevation(view, evaluationValue) but nothing changed.

I saw some applications like Swarm or Gmail apps use elevation effect for their FAB (Floating Action Button) on Pre-Lollipop devices.

Do you have an idea how they use elevation?

Pamir Cevikogullari
  • 482
  • 1
  • 6
  • 10

3 Answers3

6

You cannot use elevation pre 5.0, you need to provide an image with a "shadow" to make it appear like its elevated

tyczj
  • 71,600
  • 54
  • 194
  • 296
  • There is more information about this here http://stackoverflow.com/a/26747592/1568429 Also in this reddit thread http://www.reddit.com/r/androiddev/comments/2kd843/so_how_are_you_guys_doing_with_your_current/ – Antonio Jose Dec 14 '14 at 03:30
0

It's true than you cannot do it now but for different reason.

There is a setElevation method inter support library for pre Lollipop. But I think it's buggy and still is not usable with all types of views.

Check it out here

http://developer.android.com/reference/android/support/v4/view/ViewCompat.html#setElevation(android.view.View,%20float)

Edit: sorry, I noticed now you already tried it. I hope Google has plans to fix this soon

Antonio Jose
  • 2,778
  • 3
  • 21
  • 26
0

as mentioned in this post set background to

android:background="@android:drawable/dialog_holo_light_frame"

it looks like raised button on pre lollipop.

Community
  • 1
  • 1
kundan roy
  • 1,936
  • 1
  • 18
  • 21