CardView的使用
来源:互联网 发布:软件系统概述图 编辑:程序博客网 时间:2024/06/03 16:32
CardView的使用
CardView是在安卓5.0引入的卡片式控件。
不使用CardView效果:
使用CardView效果:
一、导包
compile 'com.android.support:cardview-v7:25.3.1'
二、xml添加控件
<?xml version="1.0" encoding="utf-8"?><android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto" app:cardBackgroundColor="@color/theme_color" app:cardCornerRadius="20dp" app:cardElevation="4dp" app:cardUseCompatPadding="true" app:contentPadding="10dp"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/user_head" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/user_head" android:layout_centerVertical="true"/> </RelativeLayout></android.support.v7.widget.CardView>
CardView属性说明:
- app:cardBackgroundColor:设置背景颜色。
- app:cardCornerRadius:设置圆角大小。
- app:cardElevation:设置阴影的高度。
- app:cardMaxElevation:设置阴影的最大高度值。
- app:cardUseCompatPadding:是否设置UseCompatPadding。v21+的版本和之前的版本仍旧具有一样的计算方式。此为卡片与父容器的边距。
- app:cardPreventCornerOverlap:是否设置PreventCornerOverlap。在v20和之前的版本中添加内边距,这个属性是为了防止卡片内容和边角的重叠。此为卡片与父容器的边距。
- app:contentPadding:设置内容的padding。此为卡片与内容的边距。
- app:contentPaddingLeft:设置内容的左padding。此为卡片与内容的边距。
- app:contentPaddingTop:设置内容的上padding。 此为卡片与内容的边距。
- app:contentPaddingRight: 设置内容的右padding。此为卡片与内容的边距。
- app:contentPaddingBottom:设置内容的底padding。此为卡片与内容的边距。
阅读全文
0 0
- CardView,RecyclerView的使用
- CardView的使用
- CardView的使用
- CardView的使用
- CardView 的使用
- CardView的使用
- Android CardView的使用
- Android CardView 的使用
- CardView的简单使用
- CardView的使用
- CardView的使用
- CardView的使用
- Android CardView的使用
- CardView 的使用
- CardView的简单使用
- CardView的详细使用
- CardView 的使用
- CardView的简单使用
- IDEA Java国际化控制台乱码
- sublime text 3安装package control
- Warning: C2819W: Header file not guarded against multiple inclusion
- Android_设置注释模板
- hbase安装 (总结2)
- CardView的使用
- MongoDB 的分组操作 In C#
- form表单提交案例
- c++加载外部库文件探究
- 软件测试的艺术第三章阅读(一)
- Fragment的onCreateView和onActivityCreate之间的区别
- Android样式的开发:shape篇
- c++ prime plus 10
- Scrapy——抓取图片