CardView介绍

CardView介绍转自 http blog csdn net u0 article details CardView 是 Android5 0 系统引入的控件 相当于 FragmentLayo 布局控件然后添加圆角及阴影的效果 CardView 被包装为一种布局 并且经常在 ListView 和 RecyclerView 的 Item 布局中 作为一种容器使用 CardView 应该被使

转自:http://blog.csdn.net/u0/article/details/

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

使用

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文件下

 
    <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; @Override protected 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难度不大,当是实用性及及效果是非常棒的,值得你拥有!!!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/227794.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月16日 下午8:31
下一篇 2026年3月16日 下午8:31


相关推荐

  • 2. 无门槛学会数据类型与输入、输出函数,滚雪球学 Python python 入门教程非常详细

    2. 无门槛学会数据类型与输入、输出函数,滚雪球学 Python python 入门教程非常详细python入门教程,python入门教程,python入门教程,python入门教程,python入门教2.无门槛学会数据类型与输入、输出函数,滚雪球学Pythonpython入门

    2022年7月6日
    20
  • Python list函数

    Python list函数Python 内置函数 list 介绍 使用示例和注意事项

    2026年3月26日
    2
  • mysql explain ref const_MySQL EXPLAIN 详解「建议收藏」

    mysql explain ref const_MySQL EXPLAIN 详解「建议收藏」一.介绍EXPLAIN命令用于SQL语句的查询执行计划。这条命令的输出结果能够让我们了解MySQL优化器是如何执行SQL语句的。这条命令并没有提供任何调整建议,但它能够提供重要的信息帮助你做出调优决策。先解析一条sql语句,你可以看出现什么内容EXPLAINSELECT*FROMperson,deptWHEREperson.dept_id=dept.didandper…

    2022年10月18日
    5
  • 阿里为什么要在北京建总部_阿里正式offer审批流程

    阿里为什么要在北京建总部_阿里正式offer审批流程开篇由于疫情的缘故,钉钉算是脱颖而出,下载量而话题度直线攀升,巧的是,我也在这个特殊时间里接到了阿里钉钉的邀请。本人毕业于华南地区某不知名211院校,Java方向,目前钉钉三面已经结束,基本可以说是坐上了“直通车”,收到的反馈都是比较好的,跟HR沟通感觉希望很大,按道理来说拿下offer是没有太大问题的,以下内容就是我这次的钉钉远程面试经历的一个分享和一些心得,希望对大家能够有所帮助。以下主要分享…

    2026年3月3日
    6
  • Vagrant系列(二)—-Vagrant的配置文件Vagrantfile详解

    Vagrant系列(二)—-Vagrant的配置文件Vagrantfile详解

    2022年2月8日
    41
  • 采用J2EE架构

    采用J2EE架构J2EE 是目前业界公认的企业级信息系统的支撑体系结构 是各个系统和系统内部各个组成部分之间的粘合剂 J2EE 提供了跨平台的解决方案 提供了通用的 JDBC 数据库访问接口 无缝支持通过 XML 进行系统间和系统内部的数据传递 支持 LDAP 目录访问接口 在 J2EE 体系结构中 所有的技术都是开放

    2026年3月18日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号