Android 5.x新增控件之-CardView

来源:互联网 发布:淘宝如何做全屏店招 编辑:程序博客网 时间:2024/05/18 01:27

1.作用

CardView 属于Support v7 里面的新的Widget.  扩展于FrameLayout,
UI显示主要包括
1.边框圆角
2.有阴影Shadow
用来突出个性,比如展览,相册等。

2.使用

2.1 引入compile 'com.android.support:cardview-v7:21.0.+' 

2.2 布局文件中加入xmlns:card_view="http://schemas.android.com/apk/res-auto"

2.3定义CardView标签
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"              xmlns:card_view="http://schemas.android.com/apk/res-auto"              android:layout_width="match_parent"              android:layout_height="65dp">    <android.support.v7.widget.CardView        xmlns:card_view="http://schemas.android.com/apk/res-auto"        android:id="@+id/card_view"        android:layout_width="match_parent"        android:layout_height="50dp"        card_view:cardBackgroundColor="@android:color/white"        android:layout_marginLeft="10dp"        android:layout_marginRight="10dp"        android:layout_marginTop="5dp"        android:layout_marginBottom="5dp"        card_view:cardCornerRadius="10dp"        card_view:cardElevation="24dp">    <TextView        android:id="@+id/title_tv"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:padding="15dp"        android:textColor="#000000"        android:textSize="16sp"        />    </android.support.v7.widget.CardView></LinearLayout>

3.重要属性

 card_view:cardCornerRadius="10dp"  圆角的半径
 card_view:cardElevation="24dp"         阴影shadow

4.其他博文

http://blog.csdn.net/birdsaction/article/details/45197499
官方文档
https://developer.android.google.cn/reference/android/support/v7/widget/CardView.html


原创粉丝点击