android中cardview的基本使用

来源:互联网 发布:腾讯电脑管家 游戏优化 编辑:程序博客网 时间:2024/05/18 13:06

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布局文件

<android.support.v7.widget.CardView 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


0 0