转自:http://blog.csdn.net/u010498248/article/details/52524053

CardView是Android 5.0系统引入的控件,相当于FragmentLayout布局控件然后添加圆角及阴影的效果;CardView被包装为一种布局,并且经常在ListView和RecyclerView的Item布局中,作为一种容器使用。CardView应该被使用在显示层次性的内容时;在显示列表或网格时更应该被选择,因为这些边缘可以使得用户更容易去区分这些内容。

使用

先看效果 

首先在build.gradle文件添加依赖库

dependencies {compile fileTree(include: ['*.jar'], dir: 'libs')testCompile 'junit:junit:4.12'compile 'com.android.support:appcompat-v7:24.2.0'compile 'com.android.support:cardview-v7:24.2.0'
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

布局文件main.html文件下

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"><android.support.v7.widget.CardView
        android:id="@+id/cardView"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_margin="10dp"><LinearLayout
            android:layout_width="match_parent"android:layout_height="100dp"><ImageView
                android:layout_width="150dp"android:layout_height="match_parent"android:layout_margin="5dp"android:scaleType="centerCrop"android:src="@drawable/sng" /><LinearLayout
                android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><TextView
                    android:layout_width="match_parent"android:layout_height="wrap_content"android:padding="5dp"android:text="棒冰行动"android:textSize="18sp"android:textStyle="bold" /><TextView
                    android:layout_width="match_parent"android:layout_height="wrap_content"android:padding="5dp"android:text="棒冰行动,公益传播设计夏令营" /></LinearLayout></LinearLayout></android.support.v7.widget.CardView></LinearLayout>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45

在MainActivity.java下文件

public class MainActivity extends AppCompatActivity {private CardView cardView;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);cardView = (CardView)findViewById(R.id.cardView);cardView.setRadius(8);//设置图片圆角的半径大小cardView.setCardElevation(8);//设置阴影部分大小cardView.setContentPadding(5,5,5,5);//设置图片距离阴影大小}
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

好,已结束CardView难度不大,当是实用性及及效果是非常棒的,值得你拥有!!!

CardView介绍相关推荐

  1. Android CardView卡片布局 标签: 控件

    CardView介绍 CardView是Android 5.0系统引入的控件,相当于FragmentLayout布局控件然后添加圆角及阴影的效果:CardView被包装为一种布局,并且经常在ListV ...

  2. Android开发之CardView卡片布局

    CardView介绍 CardView是Android 5.0系统引入的控件,相当于FragmentLayout布局控件然后添加圆角及阴影的效果:CardView被包装为一种布局,并且经常在ListV ...

  3. Android——安卓卡片样式——CardView使用、CardView失效等

    本人所有博客均是记录自己的学习和爬坑的过程,顺便分享一些好用的东西给同学,没有任何商用行为,若有侵权,请及时联系本人1521976977@qq.com.如果对你有帮助的话不妨点赞呗~谢谢 卡片Card ...

  4. android微信分享走小程序流程,教你怎么把微信小程序分享到朋友圈

    教你怎么把微信小程序分享到朋友圈 2020年07月13日 | 萬仟网移动技术 | 我要评论 7月8日收到邀请,可将小程序页面分享到朋友圈.适用于内容型页面的分享,不适用于有较多交互的页面分享.该功能为 ...

  5. Android CardView 开发过程中要注意的细节

    原文出处:http://www.codeceo.com/article/android-cardview.html 2014 年,随着 Google 推出了全新的设计语言 Material Desig ...

  6. android自动生成cardview,学习使用Material Design控件(三)使用CardView实现卡片效果...

    本文主要介绍CardView的使用,CardView是继承自FrameLayout,使用比较简单,只需要用CardView包含其他View就可以实现卡片效果了. 实现效果如下: 加入依赖库 depen ...

  7. C#中gridView常用属性和技巧介绍

    1.隐藏最上面的GroupPanel gridView1.OptionsView.ShowGroupPanel=false; 2.得到当前选定记录某字段的值 sValue=Table.Rows[gri ...

  8. Android项目实战之高仿网易云音乐项目介绍

    这一节我们来讲解这个项目所用到的一些技术,以及一些实现的效果图,让大家对该项目有一个整体的认识,推荐大家收藏该文章,因为我们发布文章后会在该文章里面加入链接,这样大家找着就很方便. 目录 第1章 前期 ...

  9. Android Support Library介绍

    一.Android Support Library存在的原因 Android自第一代发布以来,它的版本更新迭代的速度可以说是非常快的,但是android又是一个移动操作系统,是面对所有的用户的,并不是 ...

  10. GitHub 上排名前 100 的 Android 开源库介绍

    转自:http://www.codeceo.com/article/github-top-100-android-libs.html 本项目主要对目前 GitHub 上排名前 100 的 Androi ...

最新文章

  1. CCleaner v5.55.7108 发布,新增软件升级功能
  2. 趣事:一根网线发起的攻击
  3. 编制一个c语言成绩记录簿_C语言学到什么程度能写推箱子
  4. linux2.6添加新硬盘,Linux_TurboLinux11添加新硬盘方法,一.Linux的硬盘识别2.6 kernel - phpStudy...
  5. android开源许可证
  6. RecycleView弹性滑动
  7. BAT经典面试题精简版(基础知识附答案)
  8. php strpo函数,php strpos函数有什么用
  9. oracle运维工作中每天巡检的必要性--job的相关问题
  10. 详解低延时高音质:声音的美化与空间音效篇
  11. bp是什么意思贷款利率,利率上bp是什么意思
  12. 第二证券|A股集体收涨,汽车产业链爆发!房地产延续强势
  13. vue3表格双击事件
  14. mapper报Cannot find class: com/kuang/dao/UserMapper
  15. 51la图片做网店流量统计
  16. No module named ‘tf_slim‘解决办法
  17. (最新)cpu天梯图 (CPU)- Processor Benchmarks
  18. 海康NVR数字通道配置
  19. 计算机科学的发展历程和未来发展方向
  20. [广告贴]印客通,令我自豪的作品

热门文章

  1. 武汉大学计算机学院成绩单,2018年武汉大学各学院总评成绩计算公式汇总
  2. SAP ERP接口解决方案实践
  3. android循环按键精灵,大神求解按键精灵固定时间循环
  4. deepin驱动精灵_Deepin 15.4.1 X64官方正式版(64位)
  5. 嵌入式Linux使用TFT屏幕:使用TinyDRM点亮ST7789V屏幕
  6. python曲线镜像_在Python中以对角方式镜像图像
  7. Python数据库sqlite3详解
  8. lightroom安卓_【安卓】多功能视频编辑器和手机专业修图软件
  9. Tera Term使用说明
  10. Kali Linux 1.0 新手折腾笔记(2013.3.21更新)