CardView繼承自FrameLayout,容許你在card視圖中顯示信息. CardView也能夠設置陰影和圓角。(其實如今不少應用都自定義了Card視圖,Google這回將card視圖做爲基本控件,能夠拿來直接使用了)html
Layout中爲CardView設置圓角使用card_view:cardCornerRadius屬性android
代碼中爲CardView設置圓角使用CardView.setRadius方法佈局
爲CardView設置背景顏色使用card_view:cardBackgroundColor屬性spa
在佈局中包含一個CardView,以下:.net
<!-- A CardView that contains a TextView --> <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" android:id="@+id/card_view" android:layout_gravity="center" android:layout_width="200dp" android:layout_height="200dp" card_view:cardCornerRadius="4dp"> <TextView android:id="@+id/info_text" android:layout_width="match_parent" android:layout_height="match_parent" /> </android.support.v7.widget.CardView>