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. Vim自动补全神器:YouCompleteMe(转)

    转自:http://blog.jobbole.com/58978/ 可能会有一段时间写linxu,免不了用vim,留着,找时间实操之 原文出处: marchtea 的博客 第一次听说这个插件还是在偶然 ...

  2. details标签和summary标签

    代码: <details open="open"> <summary>幸福度调查结果</summary> <p>对人们幸福度的调查& ...

  3. php5.4安装ecshopphp5.4问题及解决

    includes/cls_template.php line422 将 $tag_sel = array_shift(explode(" ", $tag)); 这句话拆开为两句. $tag_exp = ...

  4. web服务器的卸载

     在卸载这三个应用之前,咱们可以在终端通过运行“dkpg -l”来查看软件状态. 方法一:选择dpkg -P来卸载软件. 因为dpkg --remove只是删除安装的文件,但不删除配置文件.而dpkg ...

  5. InstallShield 创建自己的Dialog

    1.在"User Interface"-"Dialogs"下,在All Dialogs右击"New Dialogs-"创建自己的Dialog ...

  6. 【python之旅】python的基础二

    一.集合的操作 1.什么是集合?     集合是一个无序的,不重复的数据组合,它的主要作用如下: 去重:把一个列表变成集合,就自动去重 关系测试:测试两组数据之前的交集,差集,并集等关系   2.常用 ...

  7. PM【terminal】

    More Knowledge More Performance More Time 资料模组化 以知识管理为基础的项目管理 规范:ethic

  8. CocoaPods ADD private Spec Repo

    Private Pods CocoaPods is a great tool not only for adding open source code to your project, but als ...

  9. Laravel框架——任务调度(cron)

    准备: 在服务的/var/spool/cron/root文件中添加代码 cd /var/spool/cron/root 添加以下代码 * * * * * phppath 项目路径/artisan sc ...

  10. 学习Swift -- 构造器(中)

    构造器(中) 值类型的构造器代理 构造器可以通过调用其它构造器来完成实例的部分构造过程.这一过程称为构造器代理,它能减少多个构造器间的代码重复. 构造器代理的实现规则和形式在值类型和类类型中有所不同. ...