CardView_Cardio

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

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

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

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

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/183119.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)
blank

相关推荐

  • selenium 和 IP代理池

    selenium 和 IP代理池3.1seleniumselenium:Selenium是一个自动化测试工具,利用它可以驱动浏览器执行特定的动作,如点击、下拉等操作(模拟浏览器操作)同时还可以获取浏览器当前呈现的页面的源代码,做到可见即可爬Selenium支持非常多的浏览器,如Chrome、Firefox、PhantomJS等浏览器对象的初始化并将其赋值为browser对象。接下来,我们要做的就是调用…

  • 如何找到spring的官方文档[通俗易懂]

    如何找到spring的官方文档[通俗易懂]最近因为项目中遇到了一些问题,百度不到比较好的方案,就准备去看下spring的官方文档,在此记录下:1.进入springframework的官网项目页面:https://spring.io/projects/spring-framework2.点击文档,进入文档的htmlsingle模式页面,复制浏览器的地址如下图:3.地址栏的地址”https://d…

  • java 自定义异常

    java 自定义异常

  • scrollTop和scrollHeight「建议收藏」

    scrollTop和scrollHeight「建议收藏」scollTopscrollTop可以被设置为任何整数值,同时注意:如果一个元素不能被滚动(例如,它没有溢出,或者这个元素有一个”non-scrollable”属性),scrollTop将被设置为0。设置scrollTop的值小于0,scrollTop被设为0如果设置了超出这个容器可滚动的值,scrollTop会被设为最大值.总结:元素发生溢出时可以设置scrollT…

  • CSS画猪

    效果查看:http://hovertree.com/texiao/css3/6/CSS3画猪头:http://hovertree.com/texiao/css3/6/1/代码如下:转自:htt

    2021年12月22日
  • fast裸奔框架_达梦数据库导出dmp备份命令

    fast裸奔框架_达梦数据库导出dmp备份命令关于开源框架renrne-fast3.0集成达梦(DM)数据库以及遇到的小坑分享

发表回复

您的电子邮箱地址不会被公开。

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