阴影效果样式:
实现方法:
1、创建自定义属性——attrs.xml文件
<?xml version="1.0" encoding="utf-8"?> <resources><declare-styleable name="ShadowContainer"><attr name="containerShadowColor" format="color"/><attr name="containerShadowRadius" format="dimension"/><attr name="containerDeltaLength" format="dimension"/><attr name="containerCornerRadius" format="dimension"/><attr name="deltaX" format="dimension"/><attr name="deltaY" format="dimension"/><attr name="enable" format="boolean"/></declare-styleable> </resources>
2、创建自定义阴影背景ViewGroup
/*** 作者:created by meixi* 邮箱:1085220040@qq.com* 日期:2019/7/18 17*/public class ShadowContainer extends ViewGroup {private final float deltaLength;private final float cornerRadius;private final Paint mShadowPaint;private boolean drawShadow;
。。。。。。。。。。。。。
3、layout文件调用自定义背景view即可实现阴影效果
<com.administrator.facedete.test.ShadowContainerandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="50dp"android:layout_gravity="center"app:containerCornerRadius="5dp"app:containerDeltaLength="5dp"app:containerShadowColor="#095493"app:containerShadowRadius="5dp"><LinearLayoutandroid:layout_width="80dp"android:layout_height="80dp"android:background="@drawable/pt"/></com.administrator.facedete.test.ShadowContainer>
自定义阴影demo链接:https://download.csdn.net/download/meixi_android/11387225
附阴影属性: