android中cardview的基本使用

cardView的基本使用   留个demo 做个小小的备份

cardView个人感觉类似于xml布局  shape的效果

首先在项目的build.gradle中添加引用

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
}

xml布局文件

xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginTop="20dp"
    app:cardBackgroundColor="#303069"
    app:cardCornerRadius="8dp"
    >
主要属性

  • app:cardElevation 阴影的大小
  • app:cardMaxElevation 阴影最大高度
  • app:cardBackgroundColor 卡片的背景色
  • app:cardCornerRadius 卡片的圆角大小
  • app:contentPadding 卡片内容于边距的间隔
重要一点cardView继承Framelayout


你可能感兴趣的:(布局细节代码,android,布局)