Android之CardView的使用
来源:互联网 发布:mfp126a 有网络口吗 编辑:程序博客网 时间:2024/05/18 13:27
介绍
android5.0 发布了新的设计语言:Material Design。而卡片布局 CardView 是 Material Design 风格的其中一个控件。
卡片控件是一个详细信息的入口点,卡片控件可能包含有关单个主题的照片,文字和链接。 需要注意的是,单个卡片布局内放置同个主题的内容,不可滥用卡片布局。谷歌在 Material Design 的说明中,标记出什么情况才需要使用 CardView。
Material Design Cards 设计介绍
简单来说,CardView 是一个具有圆角背景和阴影的 FrameLayout。
使用
下面仿造一加社区的精彩活动页面,详细了解 CardView 的使用。该 demo 主要是在一个 RecyclerView 列表中,每个 item 都用 CardView 显示。
效果图:
1.gradle 导入 CardView 包
compile 'com.android.support:appcompat-v7:25.1.1' //用于点击波纹(Ripple)效果compile 'com.android.support:cardview-v7:25.1.1'compile 'com.android.support:recyclerview-v7:25.1.1'
2.xml 方式新建一个 CardView
<?xml version="1.0" encoding="utf-8"?><android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" android:clickable="true" android:foreground="?android:attr/selectableItemBackground" app:cardBackgroundColor="#ffffff" app:cardCornerRadius="4dp" app:cardElevation="4dp" app:cardPreventCornerOverlap="false" app:cardUseCompatPadding="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#ffffff" android:gravity="center_horizontal" android:orientation="vertical"> <ImageView android:id="@+id/iv_pic" android:scaleType="fitXY" android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@drawable/img1" /> <TextView android:id="@+id/tv_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000000" android:layout_margin="4dp" android:text="周末加加油" android:textSize="16sp" /> </LinearLayout></android.support.v7.widget.CardView>
代码
GitHub 地址
推荐
Android CardView官网
阅读全文
0 0
- android之CardView的使用
- Android之CardView的使用
- Android开发之CardView的使用
- 【Android - MD】之CardView的使用
- Android组件之CardView的基本使用
- Android CardView的使用
- Android CardView 的使用
- Android CardView的使用
- Android CardView 的使用
- Android CardView的基本使用
- Android RecyclerView + CardView的使用
- Android中CardView的使用
- android--UI--CardView的使用
- Android的CardView使用总结
- Android CardView的使用细节
- Android中CardView的使用
- Android CardView的简单使用
- Android新特性之CardView的简单使用
- 8.ThinkPHP 3.1.2 查询方式的一般使用1
- 闭包算法
- linux修改权限
- 浙大PAT甲级-1029
- grunt官网教程(中文版)
- Android之CardView的使用
- 详解Response、Request二
- 将数组写入txt读出后数据出错
- poj 3461 kmp算法
- 代理模式
- SpringBoot(七):SpringBoot整合Swagger2
- 1057. 数零壹(20)
- 并发AQS同步器
- TCP/IP协议之IP协议