CardviewFix 簡書位址 [https://www.jianshu.com/p/8c8b2708bdb4]
原生的CardView雖然好,但是公司UI設計必須修改陰影顔色
這個庫是基于google官方庫,是以基本屬性相同,增加三個屬性,暫時隻支援xml配置,分别是`startColor`,`endColor`,`topDelta`,意思是支援修改漸變顔色值,而`topDelta`是1.0.1版本加進來支援修改上下陰影比例的,取值範圍是-1到1的浮點值,具體效果可以看截圖
demo在另一個項目
https://github.com/bigmanLau/Tablayout去吧比卡丘
依賴方式
Step 1. Add the JitPack repository to your build file
Add it in your root build.gradle at the end of repositories:
````
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.bigmanLau:CardviewFix:1.0.3'
}
效果圖如下

第一個item就是topDelta等于-1的效果,第二個item是topDelta等于0的效果,第三個item是topDelta等于1的效果
>*注意:這個偏移量和cardCornerRadius的值有關,最大值就是cardCornerRadius的值,其實就是設定cardCornerRadius的百分比*
##### 有些同學不喜歡我貼代碼,那麼直接上我的github位址去看
具體原理看代碼
[github位址] (
https://github.com/bigmanLau/CardviewFix)
>注意問題
>1. 如果出現黑邊 需要修改主題為` <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">`
>2.其他屬性用法和原生的一樣
>3.如果出現白邊請用cardview的請設定` app:cardPreventCornerOverlap="false"`