https://developer.android.com/reference/android/support/v7/widget/CardView.html
CardView
扩展 FrameLayout
类别并让您能够显示卡片内的信息,这些信息在整个平台中拥有一致的呈现方式。CardView
组件可拥有阴影和圆角。
- 如果要使用阴影创建卡片,请使用
card_view:cardElevation
属性 - 如果要在您的布局中设置圆角半径,请使用
card_view:cardCornerRadius
属性。 - 如果要在您的代码中设置圆角半径,请使用
CardView.setRadius
方法。 - 如果要设置卡片的背景颜色,请使用
card_view:cardBackgroundColor
属性。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
... >
<!-- 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>
</LinearLayout>