@cxm-2016
2016-08-29T07:10:42.000000Z
字数 1051
阅读 2237
android no

1,在你的build.gradle文件中添加cardview库
dependencies {compile 'com.android.support:cardview-v7:X.X.X' // where X.X.X version}
2,声明你的卡片布局layout.xml.
<android.support.v7.widget.CardViewandroid:layout_width="match_parent"android:layout_height="200dp"><TextViewandroid:text="Hello World!"android:layout_width="wrap_content"android:layout_height="wrap_content"/></android.support.v7.widget.CardView>
Use
android:clipToPadding="false"on the card parent allows you to prevent posible clips in the outer shadows of the card.

1,在styles.xml文件中声明你的样式.
<style name="MyCardViewStyle" parent="Theme.AppCompat.Light"><item name="cardCornerRadius">2dp</item><item name="cardElevation">2dp</item><item name="contentPaddingBottom">24dp</item><item name="contentPaddingTop">24dp</item><item name="contentPaddingLeft">16dp</item><item name="contentPaddingRight">16dp</item><item name="cardBackgroundColor">@color/indigo</item></style>
2,通过style属性来应用你的样式.
<android.support.v7.widget.CardViewandroid:layout_width="match_parent"android:layout_height="wrap_content"style="@style/MyCardViewStyle">
