8

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 !

Hiromi
  • 209
  • 1
  • 3
  • 12

3 Answers3

3

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

Zielony
  • 16,239
  • 6
  • 34
  • 39
  • I can see a lot of card view with smooth shadow... The native one is really strong... Anyway thanks for the link and the response ! – Hiromi Jun 28 '17 at 15:14
0

In API level 28 and higher now we can use:

android:outlineAmbientShadowColor="@color/blue_buttons"
android:outlineSpotShadowColor="@color/blue_buttons"
Marina
  • 317
  • 4
  • 11
-2

I don't think there's a way to change the angle and color of the shadow, but you can try with CardView's elevation (the shadow will get more dispersed, but longer).

<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
    ... 
    card_view:cardElevation="8dp">
</android.support.v7.widget.CardView>
dud3rino
  • 517
  • 4
  • 8