Material Design 入门(二)——CardView
来源:互联网 发布:电脑版淘宝找不到仓库 编辑:程序博客网 时间:2024/06/05 19:58
上一章我们分享了TextInputLayout和TextInputEditText的使用方法,比较简单,下面我们再来分享一个小控件CardView的用法。
java.lang.Object ↳android.view.View↳android.view.ViewGroup
↳android.widget.FrameLayout
↳android.support.v7.widget.CardView
CardView是Android 5.0中新出的一个控件,从上面的继承结构树中可以看出它的父类是FrameLayout,其实CardView就是在FrameLayout的基础上添加了圆角和阴影的效果。它通常被用在ListView和RecyclerView中,作为他们的itemView出现。
上面是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:layout_marginBottom="5dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:clickable="true" app:cardCornerRadius="10dp" app:cardElevation="10dp"> <LinearLayout style="@style/CardView.Content" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <ImageView android:id="@+id/ivBook" android:layout_width="109dp" android:layout_height="135dp" android:src="@mipmap/ic_launcher" android:transitionName="书籍"/> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:orientation="vertical"> <TextView android:id="@+id/tvTitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:textAppearance="@style/TextAppearance.AppCompat.Title" android:textColor="@android:color/darker_gray"/> <TextView android:id="@+id/tvDesc" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="2dp" android:text="描述" android:textColor="@android:color/darker_gray"/> </LinearLayout> </LinearLayout></android.support.v7.widget.CardView>效果如图:
效果还是不错的,也比较简单,大家可以动手试一下,以后再有圆角的需求就不用那么麻烦了呢。推荐大家看下这篇文章 http://www.jianshu.com/p/20ba212a5f0c
0 0
- Material Design 入门(二)——CardView
- Material Design入门(二)
- Material Design UI Widgets —— CardView 卡片视图
- Material Design——CardView的简单使用
- 安卓日记——玩转Material Design(RecyclerView+CardView篇)
- Material Design之CardView
- Android Material Design 之 CardView
- Material Design控件之CardView
- Material Design 入门(一)——TextInputLayout和TextInputEditText
- Material Design 入门(一)——TextInputLayout和TextInputEditText
- Material Design控件介绍(二)——TabLayout
- Material Design整理(二)——SnackBar
- Android 之 Material Design(二)—BottomNavigationView
- Material design之New Widgets(RecyclerView CardView)
- material design(一)CardView的使用详解
- Material Design入门(三)
- Android Material Design TabLayout入门篇<二>
- material design(二) MaterialEditText
- mybaits generator 重复生成xml
- [转]【坐在马桶上看算法】算法3:最常用的排序——快速排序--作者:ahalei
- 机房收费系统—结账
- Universal-Image-Loader源码阅读(30)-CircleBitmapDisplayer
- java学习笔记
- Material Design 入门(二)——CardView
- 1. Two Sum
- Lua学习笔记(一)
- pivot的用法
- 用matlab实时读取串口数据并动态显示曲线
- CSDN如何转载
- TextUtils的使用
- DotNetBar控件的多文档界面的实现
- Java虚拟机(六)——内存溢出和内存泄露分析