Android 给图片、文字、控件、布局添加阴影效果(悬浮效果)

来源:互联网 发布:淘宝评价非欧什么意思 编辑:程序博客网 时间:2024/05/16 17:59

本文只用来做技术收藏具体内容请访问github:
https://github.com/DevLight-Mobile-Agency/ShadowLayout

git效果
这里写图片描述
我的demo效果
这里写图片描述

代码实现
1.导入

compile ‘com.github.devlight.shadowlayout:library:1.0.0’
//请使用最新版本

2.实现

<
com.gigamole.samples.ShadowLayout
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
app:sl_shadowed=”true”
app:sl_shadow_angle=”45”
app:sl_shadow_radius=”20dp”
app:sl_shadow_distance=”30dp”
app:sl_shadow_color=”#000”>

<!--在这放一些你需要添加阴影的子布局-->

<
/com.gigamole.samples.ShadowLayout
>

阴影可以用代码控制

final ShadowLayout shadowLayout = (ShadowLayout) findViewById(R.id.sl);
shadowLayout.setIsShadowed(true);
shadowLayout.setShadowAngle(45);//阴影角度
shadowLayout.setShadowRadius(20);//阴影半径
shadowLayout.setShadowDistance(30);//阴影距离
shadowLayout.setShadowColor(Color.DKGRAY);//阴影颜色

——无爱无伤,无欲则刚,祝我孤独,万寿无疆。
个人demo地址:http://git.oschina.net/azure_sword/Sample_AS

1 0
原创粉丝点击