我想知道是否可以通过材质组件为卡片设置渐变背景颜色。我正在阅读docs,,但找不到任何内容。
答案 0 :(得分:1)
在res / drawable下创建一个xml,并将cardview的背景设置为此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>