卡片布局,可设置阴影颜色,透明度,圆角大小,阴影宽度
卡片布局,可设置阴影颜色,透明度,圆角大小,阴影宽度,阴影偏移量,卡片圆角/阴影圆角独立设置,特殊阴影效果,底部阴影扭曲效果等。
dependencies {
implementation 'org.linwg1988:lcardview:1.5.4'
}
dependencies {
implementation 'io.github.linwg1988:lcardview-kt:1.0.2'
}
Kotlin 版本1.0.2 新增了部分属性(描边,渐变色等),可有效减少shape.xml的创建 现在卡片式的设计还是比较常见的,设计师们常常天马行空的设计出各种好看(emmm)的的卡片样式,但是安卓原生的CardView的局限性还是比较大的,比如没办法设置阴影的颜色,阴影的透明度等等等等;那既要满足设计师们的要求且又不往包里面添加.9图片使,那可以试试这款卡片布局。demo.apk
LCardView继承FrameLayout,使用方式与之并没有什么太大区别,下面一些动图将展示LCardView具有哪些功能:
属性说明:
xml属性名称 | 中文释义 |
---|---|
attr:shadowSize | 四边阴影宽度 |
attr:shadowStartAlpha | 阴影颜色初始透明度 |
attr:shadowFluidShape | 阴影流动形状(线性/吸附) |
attr:shadowColor | 阴影颜色RGB值(透明度此处无效) |
attr:cardBackgroundColor | 卡片背景色 |
attr:cornerRadius | 阴影圆角半径 |
attr:leftTopCornerRadius | 左上圆角半径 |
attr:rightTopCornerRadius | 右上圆角半径 |
attr:leftBottomCornerRadius | 左下圆角半径 |
attr:rightBottomCornerRadius | 右下圆角半径 |
attr:elevation | 卡片高度 |
attr:elevationAffectShadowColor | 卡片高度是否影响阴影颜色 |
attr:elevationAffectShadowSize | 卡片高度是否影响阴影宽度 |
attr:leftOffset | 卡片左半区阴影偏移量 |
attr:rightOffset | 卡片右半区阴影偏移量 |
attr:topOffset | 卡片上半区阴影偏移量 |
attr:bottomOffset | 卡片右半区阴影偏移量 |
attr:fixedContentWidth | 控件宽度是否固定为内容宽度 |
attr:fixedContentHeight | 控件高度是否固定为内容高度 |
attr:paperSyncCorner | 同步卡片圆角与阴影圆角大小 |
attr:paperCorner | 卡片圆角半径 |
attr:linearBookEffect | 线性书本阴影效果 |
attr:bookRadius | 线性书本阴影偏移角度 |
attr:curveShadowEffect | 底部阴影扭曲效果 |
attr:curvature | 底部阴影扭曲率 |
attr:useShadowPool | 是否启用阴影缓存池 |
attr:bindLifeCircle | 是否绑定生命周期 |
attr:cardBackground | 卡片背景 |
attr:gradientColors | 卡片背景渐变色 |
attr:gradientSizeFollowView | 卡片背景渐变色尺寸是否与控件尺寸一致(斜方向时配置) |
attr:gradientDirection | 卡片背景渐变色方向 |
attr:strokeWidth | 描边尺寸 |
attr:strokeColor | 描边颜色 |