前言
MaterialCardView提供了CardView的所有功能,但增加了一些自定义属性,使用起来更加方便实用。在Cardview 的基础上增加了 strokeColor strokeWidth 自定义边框等属性
一、MaterialCardView是什么?MaterialCardView是提供了更多自定义属性的CardView
二、使用步骤 1.引入库代码如下(示例):
implementation "com.google.android.material:material:1.1.0"
注意:在使用使用MaterialCardView 的时候Activity的Theme必须是Theme.MaterialComponents下的Theme
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar"
异常:
Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant)2.使用
3:属性介绍
app:strokeColor="@color/color_23d41e" //边框的颜色
app:strokeWidth="5dp" //边框的宽度
app:cardElevation="8dp" //阴影大小
app:cardCornerRadius="8dp"//角度大小
app:rippleColor="@color/color_23d41e"//点击波纹效果的颜色
总结
1:Demo源码
2:MaterialCardView源码
MaterialCardView的简单使用方法特此记录,有用的欢迎拿走,来都来了点个赞吧



