0
点赞
收藏
分享

微信扫一扫

利用CardView实现阴影效果

小亦同学321 2022-02-27 阅读 56


效果图

利用CardView实现阴影效果_xml

核心代码

  1. 添加依赖
implementation 'androidx.cardview:cardview:1.0.0'
  1. 核心xml文件
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="20dp"
card:cardCornerRadius="4dp"
card:cardElevation="10dp"
card:cardMaxElevation="10dp">

<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_gravity="center"
android:gravity="center"
android:text="望洞庭\n湖光秋月两相和,潭面无风镜未磨。\n遥望洞庭山水翠,白银盘里一青螺。" />
</androidx.cardview.widget.CardView>

完整源代码

https://gitee.com/cxyzy1/shadowByCardView



举报

相关推荐

0 条评论