shadow-layout

介绍:

ShadowLayout是一个自定义的ViewGroup,它能让自己包含的view显示出阴影效果。跟CardView相比,ShadowLayout有以下优势:可以绘制圆形阴影,可以设置阴影位置,可以设置阴影的深浅,可以设置selector的阴影。

运行效果:

使用说明:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:tools="http://schemas.android.com/tools"
              xmlns:app="http://schemas.android.com/apk/res-auto"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical"
              android:gravity="center"
              android:background="@color/background"
              tools:context="${relativePackage}.${activityClass}">
    <com.dd.ShadowLayout
            android:layout_marginTop="16dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:sl_fillColor="@color/blue"
            app:sl_shadowRadius="4dp"
            app:sl_shadowColor="@color/shadow"
            app:sl_dx="0dp"
            app:sl_dy="0dp"
            app:sl_cornerRadius="56dp">
        <ImageButton
                android:layout_width="56dp"
                android:layout_height="56dp"
                android:src="@drawable/ic_add_white"
                android:background="@drawable/fab_selector"
                tools:ignore="ContentDescription"/>
    </com.dd.ShadowLayout>
    <com.dd.ShadowLayout
            android:layout_marginTop="16dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:sl_fillColor="@color/blue"
            app:sl_shadowRadius="4dp"
            app:sl_shadowColor="@color/shadow"
            app:sl_dx="2dp"
            app:sl_dy="2dp"
            app:sl_cornerRadius="56dp">
        <ImageButton
                android:layout_width="56dp"
                android:layout_height="56dp"
                android:src="@drawable/ic_add_white"
                android:background="@drawable/fab_selector"
                tools:ignore="ContentDescription"/>
    </com.dd.ShadowLayout>
    <com.dd.ShadowLayout
            android:layout_marginTop="16dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:sl_cornerRadius="2dp"
            app:sl_fillColor="@color/blue"
            app:sl_shadowColor="@color/shadow">
        <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:minWidth="88dp"
                android:minHeight="36dp"
                android:gravity="center"
                android:textColor="@android:color/white"
                android:background="@drawable/raised_selector"
                android:textAppearance="@style/TextAppearance.AppCompat.Button"
                android:text="@string/Button"/>
    </com.dd.ShadowLayout>
    <com.dd.ShadowLayout
            android:layout_marginTop="16dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:sl_cornerRadius="2dp"
            app:sl_dx="2dp"
            app:sl_dy="2dp"
            app:sl_fillColor="@color/blue"
            app:sl_shadowColor="@color/shadow">
        <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:minWidth="88dp"
                android:minHeight="36dp"
                android:gravity="center"
                android:textColor="@android:color/white"
                android:background="@drawable/raised_selector"
                android:textAppearance="@style/TextAppearance.AppCompat.Button"
                android:text="@string/Button"/>
    </com.dd.ShadowLayout>
</LinearLayout>
已下载
0