CardView是在安卓5.0提出的卡片式控件。
dependencies:
compile 'com.android.support:cardview-v7:23.4.0'
基本属性:
app:cardBackgroundColor 设置背景颜色
app:cardCornerRadius 设置圆角大小
app:cardElevation 设置z轴的阴影
app:cardMaxElevation 设置z轴的最大高度值
app:cardUseCompatPadding 是否使用CompatPadding
app:cardPreventCornerOverlap 是否使用PreventCornerOverlap
app:contentPadding 设置内容的
CardView继承自FrameLayout,是一个容器。用于显示卡片样式的内容。很漂亮。
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"> <RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
//这里是主内容
</RelativeLayout>
</android.support.v7.widget.CardView>