【发布时间】:2020-07-15 12:09:15
【问题描述】:
我想知道是否有任何方法可以从材质组件中为卡片设置渐变背景颜色。我正在阅读docs,,但我找不到任何东西。
【问题讨论】:
-
类似于this的东西?
-
虽然
Card是一个 ViewGroup,但它是不同的。
标签: android material-components-android material-components
我想知道是否有任何方法可以从材质组件中为卡片设置渐变背景颜色。我正在阅读docs,,但我找不到任何东西。
【问题讨论】:
Card 是一个 ViewGroup,但它是不同的。
标签: android material-components-android material-components
在 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>
【讨论】: