Android实现和web中一样的阴影效果

435 阅读1分钟

Android实现和web中一样的阴影效果

阴影是画在view外部的

使用方式:

自定义view,并在onDraw中执行如下代码


 ShadowHelper.draw(canvas, this,
                Config.obtain()
                        .color(color)
                        .leftTopCorner((int) lt)
                        .rightTopCorner((int) rt)
                        .leftBottomCorner((int) lb)
                        .rightBottomCorner((int) rb)
                        .radius(radius)
                        .xOffset(xOffset)
                        .yOffset(yOffset)
        );

具体用法参考 RadiusView.java

效果

1
1
1

地址代码 https://github.com/android-notes/shadow