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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • java高级面试题及答案

    java高级面试题及答案前言Linux网络协议栈是根据TCP/IP模型来实现的,TCP/IP模型由应用层、传输层、网络层和网络接口层,共四层组成,每一层都有各自的职责。应用程序要发送数据包时,通常是通过socket接口,于是就会发生系统调用,把应用层的数据拷贝到内核里的socket层,接着由网络协议栈从上到下逐层处理后,最后才会送到网卡发送出去。而对于接收网络包时,同样也要经过网络协议逐层处理,不过处理的方向与发送数据时是相反的,也就是从下到上的逐层处理,最后才送到应用程序。网络的速度往往跟用户体验是挂钩

    2022年7月9日
    22
  • java lang illegalargument_java property

    java lang illegalargument_java propertyErrorstartingApplicationContext.Todisplaytheconditionsreportre-runyourapplicationwith’debug’enabled.2021-12-2922:52:35.557ERROR[cloud-payment-service,,,]13720—[restartedMain]o.s.b.d.LoggingFailureAnalysisReporter:************…

    2025年12月1日
    5
  • SpringBoot防止大量请求攻击

    SpringBoot防止大量请求攻击我们使用Jmeter测试同学的网站时,就会出现网站无法访问,403等错误。Anerroroccurred.Sorry,thepageyouarelookingforiscurrentlyunavailable.Pleasetryagainlater.Ifyouarethesystemadministratorofthisresourcethenyoushouldchecktheerrorlogfordetails.Faithfull

    2022年7月20日
    23
  • 感谢 Gridea,让我有动力写作

    感谢 Gridea,让我有动力写作1.真的要感谢Gridea,让我对写作产生热忱。一直有在各大博客平台输出的习惯,但是都没有持续更新。有的平台广告太多,写不下去。有的平台排版复杂,写文章1个小时,排版要2个小时。所以后面换成了静态

    2022年8月3日
    10
  • java 旅游管理系统

    java 旅游管理系统旅游系统设计分为前后网站和后台管理系统,功能点包含旅游景点信息分类展示、景点详情(地理位置、特色景点概述等)、下单预订、记录分享等功能。需搭建ftp服务:https://blog.csdn.net/weixin_44989660/article/details/111280276一:前端子系统功能需求分析1.游客注册登录功能模块:游客预定景点等操作需要先将账号密码进行注册,根据注册的账号密码登录到前端子系统中对功能模块进行操作。2.预定景点功能模块:游客遇到自己喜欢的景点信息后,可以通过点击预定景点按

    2022年6月11日
    27
  • http://www.nginx.cn/install

    http://www.nginx.cn/install

    2022年3月4日
    35

发表回复

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

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