cardView的基本使用 留个demo 做个小小的备份
cardView个人感觉类似于xml布局 shape的效果
首先在项目的build.gradle中添加引用
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:cardview-v7:23.1.1' }
xml布局文件
<android.support.v7.widget.CardView xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginTop="20dp" app:cardBackgroundColor="#303069" app:cardCornerRadius="8dp" >主要属性
app:cardElevation
阴影的大小app:cardMaxElevation
阴影最大高度app:cardBackgroundColor
卡片的背景色app:cardCornerRadius
卡片的圆角大小app:contentPadding
卡片内容于边距的间隔
重要一点cardView继承Framelayout