android 5.0新特性CardView教程
CardView 是android5.0新加入的特性,大家先别着急,由于谷歌出了cardview的兼容包,也就是android.support.v7.widget.CardView包,所以在5.0以下的系统也可以运行这个效果。什么是CardView ?就是在View的外面加上一个类似如卡片的阴影,下面放代码。
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp" > <ImageView
android:id="@+id/pic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop" /> <TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/pic"
android:layout_centerHorizontal="true"
android:gravity="center"
android:textColor="#212121"
android:textSize="16sp" />
</RelativeLayout>
这是原来的代码。下面是运行效果:
然后,只需要在Relativelayout上一行加上几行代码,就能实习卡片效果:
代码
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
card_view:cardBackgroundColor="@color/cardview_light_background"
card_view:cardCornerRadius="1dp" > <RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp" > <ImageView
android:id="@+id/pic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop" /> <TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/pic"
android:layout_centerHorizontal="true"
android:gravity="center"
android:textColor="#212121"
android:textSize="16sp" />
</RelativeLayout> </android.support.v7.widget.CardView>
实现效果:
其中:
card_view:cardCornerRadius="1dp" 是设置圆角效果。
作为对比,我们改成
card_view:cardCornerRadius="10dp"看看
下面是效果图:
明显圆角变大了。
android 5.0新特性CardView教程的更多相关文章
- Android 6.0 新特性 整理 资料来自网络
Android 6.0新特性 Runtime Permissions Doze and App Standby Apache HTTP Client Removal BoringSSL Access ...
- Android 8.0 新特性
Android 8.0 (Android Oreo(奥利奥))新特性介绍 通知渠道 - Notification Channels 通知渠道是由应用自行定义的通知内容类别,借助渠道,开发者可以让用户对 ...
- android 7.0 新特性 和对开发者的影响
android 7.0新特性 - jiabailong的专栏 - 博客频道 - CSDN.NEThttp://blog.csdn.net/jiabailong/article/details/5241 ...
- 腾讯云安全:开发者必看|Android 8.0 新特性及开发指南
欢迎大家关注腾讯云技术社区-博客园官方主页,我们将持续在博客园为大家推荐技术精品文章哦~ 背景介绍 谷歌2017 I/O开发者大会今年将于5月17-19日在美国加州举办.大会将跟往年一样发布最新的 A ...
- 开发者必看|Android 8.0 新特性及开发指南
背景介绍 谷歌2017 I/O开发者大会今年将于5月17-19日在美国加州举办.大会将跟往年一样发布最新的 Android 系统,今年为 Android 8.0.谷歌在今年3 月21日发布 Andro ...
- Android 7.0新特性
还望支持个人博客站:http://www.enjoytoday.cn 由于google目前不是无法直接在国内访问,故此,对于android 开发平台的7.0新特性做个保存.也可供大家查阅.原文转自an ...
- android 5.0新特性
Android Lollipop 面向开发人员的主要功能 Material Design 设计 注重性能 通知 以大屏幕呈现 以文档为中心 连接性能再上一级 高性能图形 音频处理功能更强 摄像头和视频 ...
- Android 5.0 新特性
Material Design Material Design简介 Material Design是谷歌新的设计语言,谷歌希望寄由此来统一各种平台上的用户体验,Material Design的特点是干 ...
- Android 6.0 新特性
首先谈一谈Android 6.0的一些新特性 锁屏下语音搜索 指纹识别 更完整的应用权限管理 Doze电量管理 Now onTap App link 在开发过程中与我们关系最密切的就是"更完 ...
随机推荐
- echarts演示笔记
http://echarts.baidu.com/doc/start.html 1.新建一个echarts.html文件,为ECharts准备一个具备大小(宽高)的Dom. <!DOCTYPE ...
- C#中string.Empty和""、null的区别
string.Empty是string类的一个静态常量,而""则表示一个空字符串. string是一种特殊的引用类型,它的null值则表示没有分配内存. 使用ILSpy反编译Str ...
- ASP.NET 后台下载文件方法
void DownLoadFile(string fileName) { string filePath = Server.MapPath(fileName);//路径 //以字符流的形式下载文件 F ...
- asp.net 内部重定向
1. /* * 2. * Context.RewritePath() * 使用给定路径重写 URL.(内部重写) * 内部请求重写 */ public static void TestTwo() { ...
- PHP学习笔记二十一【全局变量】
<?PHP //定义全局变量 global $a; $a=9; //给全局变量赋值 function test1() { global $a; $a=45; } test1(); echo $a ...
- Qwt 折线图 波形图 柱状图示例效果
Qwt 目录下有不少 example,为了快速找到想要研究使用的例子,特意把所有例子的示例效果截图下来窗口标题即是 example 下的目录名称
- Qt Creator下载
Qt官网 http://qt.digia.com qt的历史版本可以到http://download.qt-project.org/archive/qt/下载
- PROCEDURE_监测系统_数据备份存储过程—备份原始数据,每十分钟一条,取平均值
create or replace procedure proc_backup_originaldata(retCode out varchar2, -- 返回码 ...
- Ubunu下安装Docker
安装Docker步骤如下: sudo apt-get update sudo apt-get install apt-transport-https sudo apt-key adv --keyser ...
- linux软件安装(rpm,源码编译)
1.rpm(redhat package manager)管理器主要目的在于解决软件的安装.卸载.升级.查询.验证等,例如升级过程中,保留软件的配置文件,安装过程中,检查软件依赖的库文件,以及卸载过程 ...