问题
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?
回答1:
You cannot use elevation pre 5.0, you need to provide an image with a "shadow" to make it appear like its elevated
回答2:
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
回答3:
as mentioned in this post set background to
android:background="@android:drawable/dialog_holo_light_frame"
it looks like raised button on pre lollipop.
来源:https://stackoverflow.com/questions/27432343/elevation-effect-for-imagebutton-on-pre-lollipop-devices