CardView的简介和用法
来源:互联网 发布:mac webstorm使用 编辑:程序博客网 时间:2024/05/20 07:35
一、引言:
在Google I/O 2014上,Google公布了Android L Preview版本,此版本的UI有了非常大的改变,很炫很给力!同时,Google也给出了两个可以向下兼容的控件放到了V7包中,分别是RecyclerView和CardView
二、用途:
CardView 属于Support v7里面的新的Widget. 扩展于FrameLayout,
适用于突出背景1.边框圆角2.有阴影Shadow
用来突出个性,比如相册等。
二、用法:
整体用法还是比较简单的
3.1 引入cardview依赖库
点击produceStructure ,点击denpendences增加依赖库进行依赖
3.2 在布局xml文件中使用
引入命名空间:
xmlns:card_view="http://schemas.android.com/apk/res-auto"
CardView如Linearlayout、Framelayout一样都是ViewGroup,即其他控件的容器。
CardView继承于Framelayout,所以Framelayout的属性他都有,同时CardView还有几个特殊的属性:
l 其余(2.0以上)有属性cardBackgroundColor,意为CardView的卡片颜色,只能通过xml的cardBackgroundColor进行指定;
l 其余(2.0以上)有属性cardConerRadius,意为CardView卡片的四角圆角矩形程度,单位dimen(dp px sp),可以通过xml指定,也可以通过代码中的setRadius指定。
l 其余(2.0以上)有属性cardElevation,意为CardView卡片的 阴影shadow程度,单位dimen(dp px sp),可以通过xml指定,也可以通过代码中的setCardElevation指定。
四 、 demo代码示例
<android.support.v7.widget.CardView
android:id="@+id/cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
app:cardBackgroundColor="#426ab3"
card_view:cardCornerRadius="5dp"
card_view:cardElevation="3dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="wifi连接信息"
android:textColor="#fff"
android:textSize="17sp"/>
<TextView
android:id="@+id/tv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#fff"
android:textSize="17sp"/>
<TextView
android:id="@+id/tv_mac"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#fff"
android:textSize="17sp"/>
<TextView
android:id="@+id/tv_rssi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#FFF"
android:textSize="17sp"/>
</LinearLayout>
</android.support.v7.widget.CardView>
效果图:很简单,就不截取了
- CardView的简介和用法
- Android RecyclerView 和CardView的用法
- CardView的基本用法
- CardView控件的用法
- RecycleView和CardView的简单介绍和用法
- (转)CardView的基本用法
- CardView的介绍和使用
- RecyclerView和CardView的使用
- (4.1.51)CardView的基本用法
- Material Design之CardView的基本用法
- ConditionVariable的简介和用法
- Schema的简介和用法
- Android CardView 简介
- Android RecyclerView和CardView的结合使用
- Android RecyclerView的StaggeredGridLayoutManager和CardView
- RecyclerView和CardView的使用以及注意
- RecyclerView和CardView的结合使用
- RecyclerView和cardView的初次体验
- mysql innodb 优化
- linux用tar命令,快速生成一个大文件
- 数组中只出现1次的两个数字(百度面试题)
- mysql 用户管理和权限设置
- ffmpeg输入rtmp时存在内存泄露
- CardView的简介和用法
- jQuery学习笔记--选择器、过滤器片
- 线段树模板2
- Cannot make a static reference to the non-static method getLocalActivityManager() from the type Acti
- 从svn下载项目后build path替灰色,应该如何解决呢?
- iOS CocoaPods安装和使用
- IOS页面跳转卡顿问题
- Matlab 笔记之6
- Android自定义可长按 可点击不可拖动的SeekBar