上一篇的基础上,修改了,CardView的布局和点击效果

总结:

CardView的奇葩属性 :app:cardPreventCornerOverlap="false" 和园角边框重叠的效果;

实现点击事件是CardView的子布局!

注意:一个细节,没明白。

在CardView控件的属性下,android:foreground="?android:attr/selectableItemBackground"
但是其他控件实现点击水波纹效果的是 android:background="?android:attr/selectableItemBackground"

1. RecyclerViewAdapter.java

RelativeLayout cardView;//修改
ImageView news_photo;
TextView news_title;
TextView news_desc;
Button share;
Button readMore; public NewsViewHolder(final View itemView) {
super(itemView);
cardView= (RelativeLayout) itemView.findViewById(R.id.card_view);

2. news_item.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp"
> <android.support.v7.widget.CardView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="false"
app:cardCornerRadius="5dp"
app:cardPreventCornerOverlap="false"
app:elevation="2dp"
> <RelativeLayout
android:id="@+id/card_view"
android:background="?android:attr/selectableItemBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/news_header"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/news_photo"
android:scaleType="centerCrop"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="150dp"/>
<TextView
android:id="@+id/news_title"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:maxLines="1"
android:textSize="20sp"
android:padding="5dp"
android:textColor="#ffffff"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
            <TextView
android:id="@+id/news_desc"
android:maxLines="2"
android:layout_below="@+id/news_header"
android:layout_margin="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:orientation="horizontal"
android:layout_below="@+id/news_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/btn_share"
android:text="SHARE"
android:background="#00000000"
android:layout_marginLeft="10dp"
android:layout_marginRight="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btn_more"
android:background="#00000000"
android:textColor="#7AD3E0"
android:text="READ MORE"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout> </RelativeLayout> </android.support.v7.widget.CardView> </RelativeLayout>
 

RecyclerView 结合 CardView 使用(二)的更多相关文章

  1. RecyclerView 结合 CardView 使用

    准备工作:导入 1.activity_mian.xml <android.support.v7.widget.RecyclerView android:id="@+id/recycle ...

  2. Android L 之 RecyclerView 、CardView 、Palette

    转: http://blog.csdn.net/xyz_lmn/article/details/38735117 <Material Design>提到,Android L版本中新增了Re ...

  3. Android L中间RecyclerView 、CardView 、Palette使用

    RecyclerView CardView Palette <Material Design>提到,Android L版本号中新增了RecyclerView.CardView .Palet ...

  4. Android之 RecyclerView,CardView 详解和相对应的上拉刷新下拉加载

    随着 Google 推出了全新的设计语言 Material Design,还迎来了新的 Android 支持库 v7,其中就包含了 Material Design 设计语言中关于 Card 卡片概念的 ...

  5. 【android】使用RecyclerView和CardView,实现知乎日报精致布局

    完整代码,请参考我的博客园客户端,git地址:http://git.oschina.net/yso/CNBlogs 在写博客园客户端的时候,突然想到,弄个知乎日报风格的简单清爽多好!不需要那么多繁杂的 ...

  6. Android L中的RecyclerView 、CardView 、Palette的使用

    <Material Design>提到,Android L版本中新增了RecyclerView.CardView .Palette.RecyclerView.CardView为用于显示复杂 ...

  7. Android RecyclerView And CardView

    Google I/O 2014大会公布Android L系统,还有Material Design全新的设计风格.而Material Design卡片式的设计.Google Play应用商店和G+ AP ...

  8. RecyclerView解密篇(二)

    在上一篇(RecyclerView解密篇(一))文章中简单的介绍了RecyclerView的基本用法,接下来要来讲讲RecyclerView的更多用法,要实现不同的功能效果,大部分都还是在于Recyc ...

  9. RecyclerView的使用(二)

    上篇博客讲了如何导入RecyclerView . 本章将告诉小伙伴们怎么使用RecyclerView : 第一步:在布局中使用RecyclerView并且绑定控件: 第二步:自定义Adapter:(继 ...

随机推荐

  1. 推荐acm题目

    杭电  http://acm.hdu.edu.cn/onlineuser.php. 浙大  http://acm.zju.edu.cn/onlinejudge/submit.do?problemId= ...

  2. sqlserver 类似oracle的rownum功能: row_number

    select row_number() over(order by t.id ) as num,id,name from (SELECT distinct [列 0] as id ,[列 1] as ...

  3. Netty 中文教程 Hello World !详解

    1.HelloServer 详解 HelloServer首先定义了一个静态终态的变量---服务端绑定端口7878.至于为什么是这个7878端口,纯粹是笔者个人喜好.大家可以按照自己的习惯选择端口.当然 ...

  4. 单例模式(.NET)

    问题描述:         单例模式 Singleton Pattern 问题解决: (1)单例模式简介: Singleton模式要求一个类有且仅有一个实例,并且提供了一个全局的访问点.这就提出了一个 ...

  5. [设计模式] 18 备忘录模式Memento Pattern

    在GOF的<设计模式:可复用面向对象软件的基础>一书中对备忘录模式是这样说的:在不破坏封装性的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态.这样以后就可将该对象恢复到原先保存 ...

  6. hdu 1242 Rescue(BFS,优先队列,基础)

    题目 /******************以下思路来自百度菜鸟的程序人生*********************/ bfs即可,可能有多个’r’,而’a’只有一个,从’a’开始搜,找到的第一个’r ...

  7. [LeetCode]Link List Cycle

    Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using ex ...

  8. hdu 4497 GCD and LCM

    思路:易知L不能整除G时为0: 将L/G质因数分解,对于其中的因子p,个数为cnt,则至少有一个包含p^cnt,至少有一个数不包含p: 只有一个数包含p^cnt时,有C(3,1); 有2个数包含p^c ...

  9. Android 加载时在actionBar右上角添加一个加载图标

    ①首先要在Activity的  setContentView()方法前调用requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); // ...

  10. FWT 学习总结

    我理解的FWT是在二元运算意义下的卷积 目前比较熟练掌握的集合对称差卷积 对于子集卷积和集合并卷积掌握不是很熟练(挖坑ing) 那么就先来谈一谈集合对称差卷积吧 所谓集合对称差卷积 就是h(i)=si ...