CardView是Android 5.0新特性——Material Design中的一个布局控件,可以通过属性设置显示一个圆角的类似卡片的视图。

1、CardView的属性:

app:cardCornerRadius:CardView的圆角大小
app:cardElevation:CardView的阴影大小
app:cardMaxElevation:CardView最大阴影大小
app:cardPreventCornerOverlap:CardView中的内容是否和圆角重叠,true为不重叠
注:如果CardView中有一张填充布局的图片,则如果不设置cardPreventCornerOverlap为true的话,图片的四个角
会延伸到CardView的圆角之外

2、演示代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"> <android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="200.0dip"
android:layout_margin="20.0dip"
app:cardCornerRadius="10.0dip"
app:cardElevation="5.0dip"
app:cardMaxElevation="15.0dip"
app:cardPreventCornerOverlap="true"> <ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/app_name"
android:scaleType="centerCrop"
android:src="@mipmap/bg" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="THIS IS A CARDVIEW"
android:textColor="#FFFFFFFF"
android:textSize="24.0sp"
android:textStyle="bold" />
</android.support.v7.widget.CardView> </RelativeLayout>

  运行结果如图所示:

  以上就是对CardView简单使用方法的介绍,下面贴出码云上的源码,供大家参考。

DEMO地址

【Android - MD】之CardView的使用的更多相关文章

  1. ANDROID L——RecyclerView,CardView进口和使用(Demo)

    转载请注明本文出自大苞米的博客(http://blog.csdn.net/a396901990),谢谢支持! 简单介绍: 这篇文章是ANDROID L--Material Design具体解释(UI控 ...

  2. Android新组件CardView

    Android L以后,新增了一个CardView组件,Google官方应用中有不少地方是使用卡片来展示信息,背后应该就是这个CardView. 使用CardView要引入单独的support包:co ...

  3. 【Android - MD】之Snackbar的使用

    Snackbar 是 Android 5.0 新特性--Material Design 中的一个控件,用来代替 Toast ,Snackbar与Toast的主要区别是:Snackbar可以滑动退出,也 ...

  4. 【Android - MD】之CoordinatorLayout的使用

    CoordinatorLayout是Android 5.0新特性--Material Design中的一个布局控件,主要用来协调各个子视图之间的工作,也可以用来作为顶部布局.CoordinatorLa ...

  5. 【Android - MD】之NavigationView的使用

    NavigationView是Android 5.0新特性--Material Design中的一个布局控件,可以结合DrawerLayout使用,让侧滑菜单变得更加美观(可以添加头部布局). Nav ...

  6. 【Android - MD】之TextInputLayout的使用

    TextInputLayout是Android 5.0新特性--Material Design中的一个布局控件,主要用来嵌套EditText,实现数据输入时的一些效果,如: 当输入框获取焦点时,输入提 ...

  7. 【Android - MD】之TabLayout的使用

    TabLayout是Android 5.0新特性--Material Design中的一个控件,是一个标签页的导航条,常结合ViewPager完成页面导航. 和其他MD控件一样,使用TabLayout ...

  8. 【Android - MD】之FloatingActionButton的使用

    FloatingActionButton(FAB) 是 Android 5.0 新特性--Material Design 中的一个控件,是一种悬浮的按钮. FloatingActionButton 是 ...

  9. Android中的CardView使用

    Android 5.0 版本中新增了CardView,CardView继承自FrameLayout类,并且可以设置圆角和阴影,使得控件具有立体性,也可以包含其他的布局容器和控件. 1.配置build. ...

随机推荐

  1. windows phone 之手势识别(Manipulation)

    在Windows Phone 7的多触摸屏上可以检测到至少四根同时存在的手指,并且一起操作使触摸屏充分发挥效果. 在silverlight开发中通过事件来实现触屏事件的检测,包括低级别的和高级别的接口 ...

  2. DateTimePicker时间控件:

    DateTimePicker时间控件: http://xdsoft.net/jqplugins/datetimepicker/ 可以参考文档设置各种属性,格式. 用法: 首先下载datetimepic ...

  3. Java单例模式深入详解

    原文地址:http://www.cnblogs.com/hxsyl/ 仅作为笔记收藏…… 一.问题引入 偶然想想到的如果把Java的构造方法弄成private,那里面的成员属性是不是只有通过stati ...

  4. C++ xmmp IM开发笔记(一)

    XMMP C++库采用 gloox (client) 下载地址:http://camaya.net/download/gloox-1.0.11.tar.bz2 glooxd (server) 下载地址 ...

  5. css字体大小设置em与rem的区别

    em 单位em是相对于父元素的,如果父元素没有设置字体大小,那就会追溯到body. 比如  如果我在box_text的父元素box加了一个字体大小   那么body的8px就会被box_text的父元 ...

  6. 读取XML文件节点数据

    xml测试文件为 <?xml version="1.0" standalone="yes"?> <NewDataSet> <xs: ...

  7. CSS2简写代码(优化)

    [1]如果CSS属性值为0,那么你不必为其添加单位(如:px/em): 下面是你可能的写法: padding: 10px 5px 0px 0px; 但是你可能这样写: padding: 10px 5p ...

  8. c++中的vector原理

    vectorvector就是动态数组.它也是在堆中分配内存,元素连续存放,有保留内存,如果减少大小后,内存也不会释放.如果新值>当前大小时才会再分配内存. 它拥有一段连续的内存空间,并且起始地址 ...

  9. jsp表单提交中文乱码的解决

    <%@ page language="Java" contentType="text/html; charset=utf-8 "    pageEncod ...

  10. [译]36 Days of Web Testing(五)

    Day 23 禁用CSS  Disable CSS 为什么 ? CSS,层叠样式表,是用来定义web页面布局和显示的机制.通过修改CSS样式,可以改变整个页面的外观. 但是有一些人,因为之前的选择或者 ...