美文网首页开源库挖掘&推荐
让你的Android控件加阴影

让你的Android控件加阴影

作者: 5afd372c86ba | 来源:发表于2017-11-07 14:08 被阅读67次
名称 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控件加阴影

    本文链接:https://www.haomeiwen.com/subject/zxlppxtx.html