0

In Lollipop we set a view's Shadow by setElevation() method.

But in pre-Lollipop, it doesn't work.

What is the best approach so that the View will have identical look when displayed on pre-lollipop devices and lollipop devices?

JayVDiyk
  • 4,277
  • 22
  • 70
  • 135
  • You're not making sense. And yes, since the question is exactly the same (how to make elevation work on pre-lollipop), it's a dupe unless you can explain how yours differ from the linked question. Please note if the provided answers don't work for you, you need to specify why to make your question different... – 2Dee Jan 06 '16 at 13:13
  • @VipulAsri Your link is more relevant! – JayVDiyk Jan 06 '16 at 13:14

1 Answers1

1

There's a bunch of approaches and each of them has its pros and cons:

  1. Draw shadows using generated gradients. Design Support Library does that. This approach supports dynamic shadows and is pretty fast. Doesn't fit into the drawing code well - usually you have to add it as a background and modify paddings.
  2. Draw shadows using 9patches. Better quality, probably faster than gradients. Doesn't support dynamic shadows and needs modified paddings and backgrounds as well.
  3. Draw shadows using RenderScript. The best quality, dynamic shadows and easy integration. It's the slowest approach and you need to setup RenderScript. Carbon draws shadows using RenderScript.
Zielony
  • 16,239
  • 6
  • 34
  • 39