android 5.0新特性学习--CardView

 CardView继承自FrameLayout类,可以在一个卡片布局中一致性的显示内容,卡片可以包含圆角和阴影。CardView是一个Layout,可以布局其他View.

官网地址:https://developer.android.com/reference/android/support/v7/widget/CardView.html

继承关系:

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ android.support.v7.widget.CardView

CardView的属性:

  elevation --CardView的Z轴阴影(也就是阴影的高度)“android:elevation = "100dp";

  cardBackgroundColor--CardView的卡片颜色(cardView背景颜色);

  cardConerRadius -- CardView卡片的四角圆角矩形程度(cardview圆角半径);

下面xml文件中即表示这个card控件为:矩形程度为8dp,背景颜色为黑色的卡片。

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"  
    xmlns:app="http://schemas.android.com/apk/res-auto"  
    android:id="@+id/cardview"  
    app:cardCornerRadius="8dp"  
    app:cardBackgroundColor="@color/black"  
    android:layout_margin="8dp"  
    android:layout_height="80dp"  
    android:layout_width="match_parent">  
  
    <TextView  
        android:text="TextView in CardView"  
        android:layout_gravity="center"  
        android:textSize="26sp"  
        android:textColor="@color/l_white"  
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content" />  
</android.support.v7.widget.CardView>  
原文地址:https://www.cnblogs.com/androidsuperman/p/4192538.html