listview的条目(item)如何做出卡片效果
卡片,其实就是一张背景图片,但做也还需要注意一点。
错误做法:
- <?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:orientation="vertical" >
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:background="@drawable/selector_list_item_bg"
- android:padding="5dp"
- >
- </LinearLayout>
- </LinearLayout>
只需要轻轻的把padding改成margin即可。因为卡片其实就是用里面的线性布局跟外面的线性布局之间生成一定的间距才形成。
正确做法:
- <?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:orientation="vertical" >
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_margin="5dp"
- android:background="@drawable/selector_list_item_bg"
- android:orientation="vertical" >
- </LinearLayout>
- </LinearLayout>
完整布局文件:
- <?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:orientation="vertical"
- >
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="5dp"
- android:layout_marginRight="5dp"
- android:background="@drawable/selector_list_item_bg"
- android:orientation="vertical" >
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:padding="10dp" >
- <ImageView
- android:id="@+id/iv_icon"
- android:layout_width="45dp"
- android:layout_height="45dp"
- android:layout_centerVertical="true"
- android:layout_marginRight="10dp"
- android:src="@drawable/ic_default" />
- <TextView
- android:id="@+id/tv_name"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_toRightOf="@+id/iv_icon"
- android:text="应用名称"
- android:textColor="#000"
- android:textSize="18sp" />
- <RatingBar
- android:id="@+id/rb_bar"
- android:layout_width="wrap_content"
- android:layout_height="15dp"
- android:layout_below="@+id/tv_name"
- android:isIndicator="true"
- android:layout_marginTop="5dp"
- android:layout_toRightOf="@+id/iv_icon"
- android:progressDrawable="@drawable/custom_ratingbar"
- android:rating="2" />
- <TextView
- android:id="@+id/tv_size"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/rb_bar"
- android:layout_toRightOf="@+id/iv_icon"
- android:text="3.7MB"
- android:textColor="#5000"
- android:textSize="16sp" />
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:layout_centerVertical="true"
- android:gravity="center"
- android:orientation="vertical" >
- <ImageView
- android:id="@+id/iv_download"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/ic_download" />
- <TextView
- android:id="@+id/tv_download"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="下载"
- android:textColor="#000"
- android:textSize="18sp" />
- </LinearLayout>
- </RelativeLayout>
- <View
- android:layout_width="match_parent"
- android:layout_height="0.2dp"
- android:background="#2000" />
- <TextView
- android:id="@+id/tv_des"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="5dp"
- android:singleLine="true"
- android:text="巴拉巴拉拉巴拉巴拉拉巴拉巴拉拉巴拉巴拉拉巴拉巴拉拉巴拉巴拉拉巴拉巴拉拉巴拉巴拉拉巴拉巴拉拉巴拉巴拉拉巴拉巴拉拉巴拉巴拉拉巴拉巴拉拉巴拉巴拉拉巴拉巴拉拉巴拉巴拉拉"
- android:textColor="#5000" />
- </LinearLayout>
- </LinearLayout>
listview的条目(item)如何做出卡片效果的更多相关文章
- listview指定某item的点击效果
需求:listview的某些item能够点击,需要点击效果,有些item不能点击,需要屏蔽点击效果. 实现: 1.layout: <ListView android:id="@+id/ ...
- Listview的条目item内的点击响应事件
还是这张图 这里的历史列表就是一个ListView,抛开该界面中ScrollView或者RecycleView与该ListView会有冲突,所谓的冲突,说白了就是父控件与子控件两者间的关系冲突,该冲突 ...
- Android SwipeToDismiss:左滑/右滑删除ListView条目Item
<Android SwipeToDismiss:左右滑动删除ListView条目Item> Android的SwipeToDismiss是github上一个第三方开源框架(githu ...
- Android中Listview点击item不变颜色以及设置listselector 无效
Android中Listview点击item不变颜色以及设置listselector 无效 这是同一个问题,Listview中点击item是会变颜色的,因为listview设置了默认的listsele ...
- Android ListView实现单击item出现删除按钮以及滑动出现删除按钮
我自己一个人弄的公司的产品客户端,所以还是想记录下来以免忘记或者丢失... 在我的上一篇博文(点击打开链接)是一个文件管理的东西,基础组件也是ListView所以在此只是改动一下而已. 单击: 点击出 ...
- RN中listView的每个item等高
今天写ListView的每个Item的布局的时候发现,当文字太长时被截掉了不能完全显示,检查了很久发现没有设置固定高度都是可伸缩的为什么没有伸缩呢.看了很久才发现每个item是等高的,于是仔细检查才看 ...
- ListView遍历每个Item出现NullPointerException的异常
在使用ListView过程中我们有时候需要遍历取得每个Item项中的一些数据(比如每个Item里面有TextView,需要获取它的文本等等),但是我们在遍历过程中经常会遇到NullPointerExc ...
- ListView遍历每个Item出现NullPointerException的异常(转)
在使用ListView过程中我们有时候需要遍历取得每个Item项中的一些数据(比如每个Item里面有TextView,需要获取它的文本等等),但是我们在遍历过程中经常会遇到NullPointerExc ...
- Android ListView实现不同item的方法和原理分析
ListView实现不同item的方法和原理分析 一问题抛出Listview是android里面的重要组件,用来显示一个竖向列表,这个没有什么问题:但是有个时候列表里面的item不是一样的,如下图,列 ...
随机推荐
- sql server显示某一列中有重复值的行
sql server查询一张表 ,显示某一列中有重复值的行,可以这样写: Select * From 表名 where 列名 in(Select 列名 From Table group by 列名 h ...
- 《C++ Primer》之面向对象编程(三)
继承情况下的类作用域 在继承情况下,派生类的作用域嵌套在基类作用域中.如果不能在派生类作用域中确定名字,就在外围基类作用域中查找该名字的定义.正是这种类作用域的层次嵌套使我们能够直接访问基类的成员,就 ...
- Edit Individual GridView Cells in ASP.NET
Edit individual GridView cells without putting the entire row into edit mode.Examples using the SqlD ...
- git基本命令--远程
git clone: # clone到 <本地目录名> $ git clone <版本库的网址> <本地目录名> # 克隆版本库的时候,所使用的远程主机自动被Git ...
- hdu_2224_The shortest path(dp)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2224 题意:双调欧几里德旅行商经典问题,找一条最短回路使得该路经过所有的点 题解:dp[i][j]=d ...
- 利用DataImportHandler建索引时一直无法完成
问题研究 项目中需要利用DataImportHandler从hive中sync数据到solr.发现有时候hive sql已经执行完几个小时了,sync任务还没有完成,貌似哪里卡住了.重启solr后重新 ...
- js获取不同浏览器盒子宽度高度
DTD 已声明 IE document.documentElement.scrollHeight 浏览器所有内容高 度 ,document.body.scrollHeight 浏览器所有内容高度 do ...
- table新增空白行到首行
var str=""; str+="<tr bordercolor='#DEDEDE' bgcolor='#ffffff'>"; str+=&quo ...
- 很好的容斥思想 HDU 5514
题目描述:有n只青蛙,m个石头(围成圆圈).第i只青蛙每次只能条a[i]个石头,问最后所有青蛙跳过的石头的下标总和是多少? 思路:经过绘图我们发现,每次跳过的位置一定是k*gcd(a[i], m).然 ...
- 文件描述符和exec() close_on_exec
#include <fcntl.h> #include <iostream> #include <unistd.h> using namespace std; in ...