【Android - MD】之CardView的使用
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简单使用方法的介绍,下面贴出码云上的源码,供大家参考。
【Android - MD】之CardView的使用的更多相关文章
- ANDROID L——RecyclerView,CardView进口和使用(Demo)
转载请注明本文出自大苞米的博客(http://blog.csdn.net/a396901990),谢谢支持! 简单介绍: 这篇文章是ANDROID L--Material Design具体解释(UI控 ...
- Android新组件CardView
Android L以后,新增了一个CardView组件,Google官方应用中有不少地方是使用卡片来展示信息,背后应该就是这个CardView. 使用CardView要引入单独的support包:co ...
- 【Android - MD】之Snackbar的使用
Snackbar 是 Android 5.0 新特性--Material Design 中的一个控件,用来代替 Toast ,Snackbar与Toast的主要区别是:Snackbar可以滑动退出,也 ...
- 【Android - MD】之CoordinatorLayout的使用
CoordinatorLayout是Android 5.0新特性--Material Design中的一个布局控件,主要用来协调各个子视图之间的工作,也可以用来作为顶部布局.CoordinatorLa ...
- 【Android - MD】之NavigationView的使用
NavigationView是Android 5.0新特性--Material Design中的一个布局控件,可以结合DrawerLayout使用,让侧滑菜单变得更加美观(可以添加头部布局). Nav ...
- 【Android - MD】之TextInputLayout的使用
TextInputLayout是Android 5.0新特性--Material Design中的一个布局控件,主要用来嵌套EditText,实现数据输入时的一些效果,如: 当输入框获取焦点时,输入提 ...
- 【Android - MD】之TabLayout的使用
TabLayout是Android 5.0新特性--Material Design中的一个控件,是一个标签页的导航条,常结合ViewPager完成页面导航. 和其他MD控件一样,使用TabLayout ...
- 【Android - MD】之FloatingActionButton的使用
FloatingActionButton(FAB) 是 Android 5.0 新特性--Material Design 中的一个控件,是一种悬浮的按钮. FloatingActionButton 是 ...
- Android中的CardView使用
Android 5.0 版本中新增了CardView,CardView继承自FrameLayout类,并且可以设置圆角和阴影,使得控件具有立体性,也可以包含其他的布局容器和控件. 1.配置build. ...
随机推荐
- Convention插件与“约定”支持
主要用于Action映射和Result映射 struts2-convention-plugin-2.3.16.3.jar 会将 |--实现了com.opensymphony.xwork2.Action ...
- new Image()的用途
new Image()用途总结: 1.图片预加载 在做游戏时,为了使图片能快打开可以做预加载. 原理:创建image对象,将image对象的src分别指向需加载的图片地址,图片被请 ...
- wordpress4.0.1源码学习和摘录--函数
1.根据类型获取当前时间 function current_time( $type, $gmt = 0 ) { switch ( $type ) { case 'mysql': return ( $g ...
- Cohort Analysis Using Python
Cohort Analysis是将某一个时期内的用户划分为一个cohort,并将多个cohort进行时间上的某个属性的比较的一种分析方法.Cohort Analysis在有些场景下非常有用.比如一个网 ...
- gnuplot使用
直接用yum安装gnuplot即可,例如 sudo sh -c "yum install gnuplot.x86_64 " 安装以后就可以使用了 编写gnuplot脚本 # grp ...
- 机器视觉工具箱-Machine Vision Toolbox for Matlab
发现了一个机器视觉的Matlab工具箱,分享一下. 机器视觉工具箱(MVT的)规定,在机器视觉和基于视觉的控制有益的多种功能.这是一个有点折衷收集反映作者在光度学,摄影测量,色度学 方面的个人利益.它 ...
- Java 内存区域和GC机制--备用
Java垃圾回收概况 Java GC(Garbage Collection,垃圾收集,垃圾回收)机制,是Java与C++/C的主要区别之一,作为Java开发者,一般不需要专门编写内存回收和垃圾清理代 ...
- 提高matlab运行速度和节省空间的心得
提高matlab运行速度和节省空间的心得 首先推荐使用matlab 2006a版本,该版本优点很多(不过有一个小bug,就是通过GUI自动生成的m文件居然一大堆warning,希望在已经发布了的200 ...
- GNOME Shell叫板Ubuntu Unity:优劣PK
转自GNOME Shell叫板Ubuntu Unity:优劣PK GNOME Shell 对阵 Ubuntu Unity--默认桌面界面的战火一触即发.双方在台上已经对峙了很长时间,现在是时候决定谁会 ...
- Vim识别编码
http://blog.chinaunix.net/uid-20357359-id-1963123.html