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

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

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

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • laravel中如何实现验证码验证及使用

    laravel中如何实现验证码验证及使用

    2021年10月26日
    42
  • 【Verilog】FPGA驱动Ov7670/Ov7725搭建视频通路(RGB565、灰度图)

    【Verilog】FPGA驱动Ov7670/Ov7725搭建视频通路(RGB565、灰度图)一、课题功能指标要求(一)课程目的• 加深对数字电路时序的理解;• 掌握OV系列摄像头输出时序;• 掌握I2C总线时序,以及使用verilog驱动三态门的方法;• 掌握数字系统设计的方法;(二)设计任务o 设计并利用FPGA实现OV7670(Ov7725)~VGA(320*240)显示器的视频通路;o (基本要求)设计I2C总线接口以及控制器,实现对摄像头的配…

    2022年9月13日
    0
  • mysql读写分离的意义_MySQL读写分离

    mysql读写分离的意义_MySQL读写分离如何实现mysql的读写分离?就是基于主从复制架构,简单来说,就搞一个主库,挂多个从库,然后我们就单单只是写主库,然后主库会自动把数据给同步到从库上去。MySQL主从复制原理的是啥?主库将变更写binlog日志,然后从库连接到主库之后,从库有一个IO线程,将主库的binlog日志拷贝到自己本地,写入一个中继日志中。接着从库中有一个SQL线程会从中继日志读取binlog,然后执行binlog日志中的…

    2022年6月13日
    24
  • python编写怎么换行_python表示换行

    广告关闭腾讯云11.11云上盛惠,精选热门产品助力上云,云服务器首年88元起,买的越多返的越多,最高返5000元!windows换行符是’rn’,unixlinux的换行符为’n’,mac的换行符为’r’,在python中,对换行符进行了统一处理,定义为’n。到此这篇关于python代码中怎么换行的文章就介绍到这了,更多相关python写代码怎么换行内容请搜索zalou.cn以前的文章或继续浏…

    2022年4月9日
    227
  • java基础——java.util.ConcurrentModificationException

    在编写代码的时候,有时候会遇到List里有符合条件的的对象,就移除改对象! 但是这中操作如:使用了 List 的remove,会导致一些很严重的问题!

    2022年2月25日
    42
  • pycharm2019.2.6版本改中文_pycharm怎么更改python环境

    pycharm2019.2.6版本改中文_pycharm怎么更改python环境1.文件——设置——项目——python解释器2.点最右边的设置图标——添加3.选择现有环境——点击右边省略号4.找到你要的python版本的地址——找到python.exe——确定做完这些就完成了

    2022年8月28日
    1

发表回复

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

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