CardviewFix

Introduction: 对安卓原生 cardview 增加一个修改阴影颜色的功能和阴影上下比例
More: Author   ReportBugs   
Tags:
原生的 CardView 虽然好,但是公司 UI 设计必须修改阴影颜色

这个库是基于 google 官方库,所以基本属性相同,增加三个属性,暂时只支持 xml 配置,分别是startColorendColortopDelta,意思是支持修改渐变颜色值,而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'
    }

效果图如下 1.png

第一个 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"

请关注我的公众号,有很多免费信息和优秀小程序 扫码 _ 搜索联合传播样式-微信标准绿版.png

Apps
About Me
GitHub: Trinea
Facebook: Dev Tools