/Seachal_CardView_Set

各种自定义 cardview 合集, 自己在寻找 cardview 整理的案例。 发现只有官方的 CardView的阴影不会占用 View 的宽高,其他自定义 View 都有些问题, 对于给定比例或尺寸的 UI 效果图,还是用官放的 CardView 保险些。阴影、投影、带颜色投影、带颜色阴影、shade 、shadow 、 Elevation 、projection。

Primary LanguageKotlin

SCardView

Display :

Control the direction and color of shadow

image

Control the corner of shadow

image

How to use ?

Gradle Groovy DSL

implementation 'io.github.meetsl:SCardView:1.2'

Attribute

<attr name="cardLightDirection">
    <enum name="left" value="1" /> <!-- 设置光源位置为左侧,阴影在右侧 -->
    <enum name="right" value="2" /> <!-- 阴影在左侧-->
    <enum name="top" value="3" /> <!-- 阴影在下部-->
    <enum name="bottom" value="4" /> <!-- 阴影在上部 -->
    <enum name="LT" value="5" /> <!-- 阴影在右下角-->
    <enum name="RT" value="6" /> <!-- 阴影在左下角-->
    <enum name="LB" value="7" /> <!-- 阴影在右上角 -->
    <enum name="RB" value="8" /> <!-- 阴影在左上角 -->
    <enum name="none" value="9" /> <!-- 光源位置在正上方 -->
</attr>

<attr name="cardCornerVisibility">
     <enum name="noLeftCorner" value="1" />
     <enum name="noRightCorner" value="2" />
     <enum name="noTopCorner" value="3" />
     <enum name="noBottomCorner" value="4" />
     <enum name="noLT_RBCorner" value="5" />
     <enum name="noRT_LBCorner" value="6" />
     <enum name="none" value="7" />
</attr>

Update Log

V1.2

issue#11 Update the color of card's shadow dynamically

/**
     * Updates the shadow color of the CardView
     *
     * @param startColor The new startColor to set for the card shadow
     * @param endColor The new endColor to set for the card shadow
     */
    fun setCardShadowColor(@ColorInt startColor: Int, @ColorInt endColor: Int)

    /**
     * update the both of background color and shadow color of the card view
     */
    fun setColors(@ColorInt backgroundColor: Int, @ColorInt shadowStartColor: Int, @ColorInt shadowEndColor: Int)

issue#7 The attribute of 'layout_gravity = end|right' at the children of SCardView has no effect. This problem has been resolved.