使任意View控件产生Android MaterialDesign 中的z轴阴影效果。
效果图:
如何使用
使用很简单,只要将你想要产生阴影的View包含在即可:
android:id="@+id/zDepthShadowLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
shadow:z_depth="z_depth4">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="Change ZDepth"
android:background="@android:color/white"/>
即让TextView产生阴影
其中属性z_depth是设置阴影的大小,是个枚举值:z_depth0、z_depth1、z_depth2、z_depth3、z_depth4、z_depth5, 值越大阴影越大。你也可用java 代码设置:zDepthShadowLayout.changeZDepth(ZDepth.Depth0)
属性说明属性名称类型使用说明
z_depthenum(枚举类型)设置阴影大小,值:z_depth0、z_depth1、z_depth2、z_depth3、z_depth4、z_depth5, 值越大阴影越大
z_depth_shapeenum设置阴影形状,值:rect(矩形)、oval(椭圆形)
z_depth_paddingenum设置内间距,值:z_depth0、z_depth1、z_depth2、z_depth3、z_depth4、z_depth5, 值越大内间距越大
z_depth_paddingLeftenum设置左内间距
z_depth_paddingTopenum设置上内间距
z_depth_paddingRightenum设置右内间距
z_depth_paddingBottomenum设置下内间距
z_depth_animDurationinteger档z_depth_doAnim设置true,用于设置动画的时间
z_depth_doAnimboolean阴影是否以动画方式被设置