天天看点

CardView的介绍

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

CardView常用属性:

  • 卡片内容于边距的间隔
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        card_view:cardBackgroundColor="#303069"
        card_view:cardCornerRadius="10dp"
        card_view:cardPreventCornerOverlap="true"
        card_view:cardUseCompatPadding="true"
        card_view:contentPadding="10dp">
        ...
</android.support.v7.widget.CardView>      
  • 添加依赖
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'

    compile 'com.commit451:PhotoView:1.2.4'
    compile 'com.facebook.fresco:fresco:0.8.1'
    compile 'com.jakewharton:butterknife:7.0.1'
}