让你的Android控件加阴影

名称 LongShadow
语言 Android
平台 GitHub
作者 florent37
链接 点此进入

该库能给你的任何安卓控件加上阴影,具体效果如下图:

sample.gif

使用方法
使用方法也是非常简单

  1. 添加依赖
dependencies {
    compile 'com.github.florent37:longshadow:(lastversion)'
}
  1. 对于要加阴影的控件,只需要将其包在LongShadow布局内即可。
    给TextView 添加阴影
<com.github.florent37.longshadow.LongShadow
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/shadow"
        app:shadow_angle="60"  //阴影角度
        app:shadow_color="#739440"  //阴影颜色
        android:background="#99ca55">

        <TextView
            android:id="@+id/logo"
            android:layout_width="wrap_content"
            android:layout_height="120dp"
            android:gravity="center"
            android:textColor="#FFF"
            android:textSize="30sp"
            android:layout_gravity="center"
            android:text="hello world!" />

    </com.github.florent37.longshadow.LongShadow>
给ImageView添加阴影
<com.github.florent37.longshadow.LongShadow
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:id="@+id/shadow2"
        app:shadow_angle="140"
        app:shadow_color="#406694"
        android:background="#55a9ca">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_gravity="left|center_vertical"
            android:layout_marginLeft="70dp"
            app:srcCompat="@drawable/ic_android_white_24dp" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_gravity="right|center_vertical"
            android:layout_marginRight="70dp"
            app:srcCompat="@drawable/ic_android_white_24dp" />

</com.github.florent37.longshadow.LongShadow>

更多使用方法,请参考其GitHub。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,142评论 25 708
  • 内容抽屉菜单ListViewWebViewSwitchButton按钮点赞按钮进度条TabLayout图标下拉刷新...
    皇小弟阅读 46,878评论 22 665
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,223评论 4 61
  • 一、如何准备你的演讲 1.充分准备材料 对所搜集材料的真实性和材料本身进行深入审查和理解。 方法:有想法及时写下来...
    白二二阅读 976评论 8 15
  • 月上梢头 歌声悠悠 蓝T恤休闲裤的少年在晚风里的眼眸
    Andy_静水流深阅读 174评论 0 0