Android CardView简单使用方法
来源:互联网 发布:域名查询和注册软件 编辑:程序博客网 时间:2024/06/08 12:28
首先需要引入CardView包,compile ‘com.android.support:cardview-v7:23.0.1’
CardView常用属性
// 阴影的大小
card_view:cardElevation
// 阴影最大高度
card_view:cardMaxElevation
// 卡片的背景色
card_view:cardBackgroundColor
// 卡片的圆角大小
card_view:cardCornerRadius
// 卡片内容于边距的间隔
card_view:contentPadding
card_view:contentPaddingBottom
card_view:contentPaddingTop
card_view:contentPaddingLeft
card_view:contentPaddingRight
card_view:contentPaddingStart
card_view:contentPaddingEnd
// 设置内边距,V21+的版本和之前的版本仍旧具有一样的计算方式
card_view:cardUseCompatPadding
// 在V20和之前的版本中添加内边距,这个属性为了防止内容和边角的重叠
card_view:cardPreventConrerOverlap
然后只需要简单在XML文件中表示出来就可以了。
activity_main.xml
<?xml version="1.0" encoding="utf-8"?><android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context=".MainActivity"> <android.support.design.widget.AppBarLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /> </android.support.design.widget.AppBarLayout> <include layout="@layout/content_main" /> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" android:src="@android:drawable/ic_dialog_email" /></android.support.design.widget.CoordinatorLayout>
content_main.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" android:orientation="vertical" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:showIn="@layout/activity_main" tools:context=".MainActivity"> <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_width="200dp" android:layout_height="wrap_content" card_view:cardBackgroundColor="#303069" card_view:cardCornerRadius="10dp" card_view:cardPreventCornerOverlap="true" card_view:cardUseCompatPadding="true" card_view:contentPadding="10dp" > <TextView android:text="Title" android:textSize="20sp" android:textColor="#fffffc31" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </android.support.v7.widget.CardView> <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_width="250dp" android:layout_height="wrap_content" card_view:cardBackgroundColor="#FF0E63FF" card_view:cardCornerRadius="10dp" card_view:cardPreventCornerOverlap="true" card_view:cardUseCompatPadding="true" card_view:contentPadding="10dp" > <LinearLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:text="Title" android:textSize="20sp" android:textColor="#ff24ff60" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:text="SubTitle" android:textSize="15sp" android:textColor="@color/colorAccent" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> </android.support.v7.widget.CardView></LinearLayout>
- Android CardView简单使用方法
- android-cardview简单使用
- Android CardView的简单使用
- android 一个简单的CardView的 使用
- Android 中简单使用RecyclerView 和CardView
- Android中CardView的简单使用
- CardView的具体使用方法
- android cardview
- Android CardView
- Android L 新增UI控件:RecyclerView CardView的简单使用
- Android新特性之CardView的简单使用
- Android新特性之CardView的简单使用
- Android新特性之CardView的简单使用
- Android新特性之CardView的简单使用
- Android新特性之CardView的简单使用
- Android新特性之CardView的简单使用
- Android新特性之CardView的简单使用
- (转)Android新特性之CardView的简单使用
- TortoiseSVN 锁的使用
- iOS开发工具篇-AppStore统计工具
- 如何在Mac上安装Ruby
- 安卓开发环境安装--菜鸟之路(二)
- 1008. Elevator
- Android CardView简单使用方法
- 取消显示 Actionbar
- [BZOJ1651] [Usaco2006 Feb]Stall Reservations 专用牛棚
- 黑马程序员——反射
- iOS开发流程总结
- 内蒙古大学教务处脱表名脚本
- 1009. Product of Polynomials
- 10大iOS开发者最喜爱的库
- 最大公约数(更相减损法)