I was wondering if there is any way to set a gradient background color to a Card from the Material Components. I was reading through the docs, but I couldn't find anything.
Asked
Active
Viewed 825 times
2
-
Something similar to [this](https://stackoverflow.com/questions/52908045/how-to-set-a-gradient-background-in-a-material-button-from-material-components?rq=1)? – Parth Shah Jul 15 '20 at 12:12
-
It's different though once a `Card` is a ViewGroup. – Augusto Carmo Jul 15 '20 at 12:23
1 Answers
0
Create an xml below res/drawable and set the background of your cardview to this xml.
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="@color/colorPurple"
android:endColor="@color/colorBlue"
android:angle="0"/>
</shape>

Ümit Bülbül
- 512
- 2
- 15