Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CardView how to change shadow color and angle?

How to change shadow color and angle in CardView ? I've put cardview_shadow_start_color and cardview_shadow_end_color into colors.xml but no colors changes... Txs !

like image 761
Hiromi Avatar asked Jun 28 '17 14:06

Hiromi


People also ask

How do I change the color of my card shadow?

Use Fake Shadow. xml ) in the parent layout which is looking like a shadow. You can replace FF46A9 in shadow. xml to change the color of shadow. Also android:backgroundTint="@color/colorShadow" works but you have to adjust colors alpha in shadow.

How do I customize my CardView?

Customized CardView First, add a CardView dependency to the application-level build. gradle file. Then create a drawable background for the cards. For that, create a new drawable resource file inside the drawable folder.

What is card elevation in CardView?

Note that the card_view:cardElevation is used to determine the size and softness of the shadow so as to realistically depict the depth. These properties can be set programmatically as well: CardView card = ... card.


1 Answers

There's no way to change shadow color and angle in the official Android framework. The color is always black and the angle is generated automatically using view's position. Moreover, on older platforms CardView's shadow is a completly different thing than on Lollipop, so the angle won't work at all.

For colored shadows you can use a library called Carbon. See this answer: Android change Material elevation shadow color

like image 166
Zielony Avatar answered Nov 11 '22 15:11

Zielony