先初始化 xmlns:card_view="http://schemas.android.com/apk/res-auto"
card_view:cardElevation
设置阴影
card_view:cardCornerRadius
设置角度
card_view:cardBackgroundColor
设置背景色
card_view:card
UserCompatPadding 设置padding填充在版本L之前和之后的填充效果一致,避免版本L之前会不显示阴影
<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:cardElevation="4dp" card_view:cardCornerRadius="4dp" 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>
时间: 2024-11-05 20:35:42