ZieIony / Carbon

Material Design implementation for Android 4.0+. Shadows, ripples, vectors, fonts, animations, widgets, rounded corners and more.

Home Page:https://androidreclib.wordpress.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can you separate the shadowView?

opened this issue · comments

My min api is 21, I don't want to use the whole carbon, because I only like this shadowView that can change the color.

Can u help me?thanks~

English is not good...forgive me...

No problem, your english is fine.

I'm sorry, but this is not possible. Shadows are tightly integrated with the rest of this library. To extract shadows I would need to also copy reveal animators, elevation system, all layouts and views (because drawing shadows is implemented in views and done by layouts) and shadow shapes.

Ok, thank you~and also, setShadowLayers it is the principle of carbon shadowView?

No, because setShadowLayer forces the corresponding layer to be rendered in software. Carbon's shadows are using a similar technique, but with some optimizations and hardware acceleration. The algorithm is as follows:

  1. Generate a 9 patch shape of the view.
  2. Blur that 9 patch using elevation to compute blur radius; cache it.
  3. Draw the 9 patch; clip it to the view and reveal animation; then draw the view on top of it.

It's great! I really like this feature.

Thanks answer~