I’m working with material design and I faced the problem I can’t solve. It’s about the shadows/elevation.
- Here we can read about the shadows and elevations in Material Design
https://developer.android.com/training/material/shadows-clipping.html#Shadows
But we can use these features only in lollipop and higher.
And what about the pre-lollipop devices? If I want to create the app which could be used at pre-lollipop devices then I can’t use, for example
android:elevation=”2dp”
Am I right?
- If so then all I can do – it’s using the design drawables which already include their shadows.
And here’s another issue that I can’t get.
For example, the designer gives me psd with some design. Imagine it looks like this
As you can see, top margin of the panel is 448px. We can easily get this margin value using the Photoshop.
But when I extracted this panel with its shadow then I discover that shadow by itself takes 10 px at the top of the panel
That 448px top margin doesn’t count the shadow.
Obviously I can’t just put panel.png on my some_layout.xml and set the margin top as 448px(298.67dp) because this drawable includes the shadow. It seems I should consider the shadow length and I should deduct this length from the top margin (448-10=438px=292dp).
Is this reasoning correct? I just can’t believe it. This way seems to be too complicated. Maybe more effective practice exists?
2
Answers
According to
shadow
in Pre Lollipop devicesRead more: Add elevation/shadow on toolbar for pre-lollipop devices
According to
elevation
in Pre Lollipop devicesRead more: How to implement the Material-design Elevation for Pre-lollipop
EDIT: As @geek90 suggest visit also this repo: http://github.com/navasmdc/MaterialDesignLibrary
It frustrated me too. I didn’t like making shadows with gradients. I dove into the documentation, found how is the Lollipop’s implementation done and coded that from scratch for older devices.
My implementation is called Carbon. It’s a Material Design implementation with support for dynamic, automatic shadows. No need to add any kind of margin or gradient – just specify elevation for a view and get shadows on all SDKs.
https://github.com/ZieIony/Carbon
Read more about the method here: How to implement the Material-design Elevation for Pre-lollipop