项目中要使用到CardView,就自己总结了一下CardView的使用方法。
0. libs要加上
android-support-v4.jar
android-support-v7-cardview.jar
1. 项目中要引用
android-sdk-windows\extras\android\support\v7\cardview 的工程项目
2. 在顶层layout上加上
xmlns:app="http://schemas.android.com/apk/res-auto"
如
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout >
3. 使用上如下:
app:cardBackgroundColor背景颜色
app:cardElevation阴影长度
app:cardCornerRadius圆角半径
<android.support.v7.widget.CardView
android:id="@+id/cardview"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardBackgroundColor="#ff0000"
app:cardCornerRadius="0dp"
app:cardElevation="0dp">