Change Card View Elevation Color
here you can change color first you can make a drawable file and paste this code in it. then in your layout inside cardview, you can assign as background file.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:bottomLeftRadius="8dp"
android:topLeftRadius="5dp"
android:bottomRightRadius="8dp"
android:topRightRadius="5dp"/>
<solid android:color="#ddd"/>
</shape>
</item>
Android change Material elevation shadow color
I know that this question is very old and probably the author doesn't need the answer anymore. I'll just leave it here so others can find it.
Lollipop's elevation system doesn't support colored shadows.
But, if you need colored shadows, it's possible to get them using Carbon. It's a kind-of support library for Material Design and in the most recent version there is an option to change shadow color. There's a ton of nice designs on Behance featuring colored shadows and I thought it would be nice to have them despite lack of such feature in Android. It's important to note that colored shadows are emulated on all Android versions, on 5.0+ too.
https://github.com/ZieIony/Carbon
The following image and code can be found in Carbon's samples.
Code:
<carbon.widget.LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<carbon.widget.Button
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_margin="@dimen/carbon_padding"
android:background="#ffffff"
app:carbon_cornerRadius="2dp"
app:carbon_elevation="8dp"
app:carbon_elevationShadowColor="@color/carbon_red_700"/>
</carbon.widget.LinearLayout>
"CardView":
<carbon.widget.LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<carbon.widget.LinearLayout
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_margin="@dimen/carbon_margin"
android:background="#ffffff"
app:carbon_cornerRadius="2dp"
app:carbon_elevation="8dp"
app:carbon_elevationShadowColor="@color/carbon_red_700">
<carbon.widget.ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:src="@drawable/test_image"/>
<carbon.widget.TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="test text"/>
</carbon.widget.LinearLayout>
</carbon.widget.LinearLayout>
Related Topics
How to Painlessly Change My App Title Text Color
How to Open a New Fragment from Another Fragment
Download Failed Because the Resources Could Not Be Found
How to Make User Login from Only One Device At a Time
How to Make Android Device Boot When Power Is Plugged In
How to Handle Notification When App in Background in Firebase
Storage Permission Error in Marshmallow
What Is the Simplest and Most Robust Way to Get the User'S Current Location on Android
Send Data from Activity to Fragment in Android
Why Is the Android Emulator So Slow? How to Speed Up the Android Emulator
How to Get the Current Gps Location Programmatically in Android
Onactivityresult Is Not Being Called in Fragment
How to Declare Global Variables in Android
How to Add a Library Project to Android Studio
Change App Language Programmatically in Android
Ship an Application With a Database
Android Shared Preferences For Creating One Time Activity (Example)