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


相关推荐

  • Lucene.net(4.8.0) 学习问题记录二: 分词器Analyzer中的TokenStream和AttributeSource[通俗易懂]

    Lucene.net(4.8.0) 学习问题记录二: 分词器Analyzer中的TokenStream和AttributeSource[通俗易懂]前言:目前自己在做使用Lucene.net和PanGu分词实现全文检索的工作,不过自己是把别人做好的项目进行迁移。因为项目整体要迁移到ASP.NETCore2.0版本,而Lucene使用的版本是3.6.0,PanGu分词也是对应Lucene3.6.0版本的。不过好在Lucene.net已经有了Core2.0版本,4.8.0bate版,而PanGu分词,目前有人正在做,貌似已经做完,只是…

    2022年7月22日
    12
  • Ubuntu16.04 apache2配置虚拟主机[通俗易懂]

    Ubuntu16.04 apache2配置虚拟主机[通俗易懂]1.首先在“/etc/hosts”文件中加入当前主机的IP地址和需要设置的虚拟主机名: 如:192.168.0.143www.moyaping2.com 2.在“/etc/apache2/sites-available”目录下有“000-default.conf” 将000-default.conf复制一份叫做redis.conf 3进入redis.conf 修改Se

    2022年9月18日
    0
  • 动态规划:完全背包、多重背包[通俗易懂]

    动态规划:完全背包、多重背包[通俗易懂]一、问题描述:  完全背包:有N种物品和一个容量为V的背包,每种物品都有无限件可用。第i种物品的费用是c[i],价值是w[i]。求解将哪些物品装入背包可使这些物品的费用总和不超过背包容量,且价值总和最大。      多重背包:有N种物品和一个容量为V的背包。第i种物品最多有n[i]件可用,每件费用是c[i],价值是w[i]。求解将哪些物品装入背包可使这些物品的费用总和不超过背包容量,且价值…

    2022年7月26日
    5
  • WPF-visifire Charts 控件去掉水印

    WPF-visifire Charts 控件去掉水印WPF-visifireCharts控件去掉水印,亲自测试可用!

    2022年7月21日
    11
  • html、css 实现二级菜单「建议收藏」

    html、css 实现二级菜单「建议收藏」利用html、css实现二级菜单,一级菜单用浮动,二级菜单用定位

    2022年5月31日
    28
  • NestedScrollView+Viewpager+Recycleview的滑动冲突

    NestedScrollView+Viewpager+Recycleview的滑动冲突最新业务需求变化 一个页面多个 Recycleview Viewpager viewpager 实现左右滑动 且可以手动滑动 页面逻辑简单 就是数据比较大 最初的时候实现有滑动冲突 后边使用 NestedScroll 可以实现滑动 但是 Viewpager 不能实现手动滑动 Recycleview 的 item 事件冲突 这个只在华为 7 0 手机上出现 华为 8 0 及三星手机上未发现问题 网上也是各种找 后边看

    2025年7月3日
    0

发表回复

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

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