I am using 'com.android.support:cardview-v7:23.4.0'
and I see the shadow but is not a dark grey shadow, and I would like to get a darker elevation shadow, but I do not see any attribute to get it, any ideas?
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginRight="8dp"
android:layout_marginLeft="8dp"
android:layout_marginBottom="8dp"
app:cardElevation="8dp"
app:cardPreventCornerOverlap="false"
app:cardCornerRadius="1dp"
app:cardUseCompatPadding="false">
<include layout="@layout/any_layout"/>
</android.support.v7.widget.CardView>
I believe that the shadow intensity is defined by the underlying theme that the app uses. So for API level more than 21, you can override the intensity of shadows. In your styles.xml
add these two extra lines of ambientShadowAlpha
and spotShadowAlpha
. Please note that these values range from 0 to 1, with 0 being completely transparent and 1 being completely opaque(almost black) :
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:fontFamily">@font/barlow_family</item>
<item name="android:ambientShadowAlpha">1</item>
<item name="android:spotShadowAlpha">1</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:statusBarColor">@android:color/background_light</item>
</style>