listView使用中的一些技巧

转自

http://blog.csdn.net/liuhanhan512/article/details/7225989

http://blog.csdn.net/janronehoo/article/details/7240241

去除ListView滑到顶部和底部时边缘的黑色阴影:

Xml代码  
  1. android:fadingEdge="none"  
[xml]  view plain copy
  1. android:fadingEdge="none"  

  

去除拖动时默认的黑色背景:

Xml代码  
  1. android:cacheColorHint="#00000000"  
[xml]  view plain copy
  1. android:cacheColorHint="#00000000"  

 

去除选中时的黄色底色:

Xml代码  
  1. android:listSelector="#00000000"  
[xml]  view plain copy
  1. android:listSelector="#00000000"  

去除行与行之间的黑线:

Java代码  
  1. msgList.setDivider(null);  
[java]  view plain copy
  1. msgList.setDivider(null);  

ListView刷新后自动滚到最底部:

Java代码  
  1. msgList.setSelection(msgList.getAdapter().getCount()-1);  
[java]  view plain copy
  1. msgList.setSelection(msgList.getAdapter().getCount()-1);  

 以上,自然也可以进行自定义颜色处理。






listview 拖动 背景图 显隐    2013 - 07 -19

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
<!-- 最后一条item所在的位置会闪烁 -->
    
             < ListView
                 android:id = "@+id/recommand_app_list"
                 android:layout_width = "fill_parent"
                 android:layout_height = "fill_parent"
                 android:layout_below = "@id/recommands_list_view_header_divider"
                 android:fadingEdge = "none"
                 android:scrollbars = "none"
                 android:scrollingCache = "true" 
             </ ListView
    
    
    
<!--修复问题: 最后一条item所在的位置会闪烁 -->
    
             < ListView
                 android:id = "@+id/recommand_app_list"
                 android:layout_width = "fill_parent"
                 android:layout_height = "fill_parent"
                 android:layout_below = "@id/recommands_list_view_header_divider"
                 android:background = "@drawable/ic_content_bg_repeat"
                 android:divider = "@drawable/ic_list_divider_repeat"
                 android:dividerHeight = "1dp"
                 android:fadingEdge = "none"
                 android:persistentDrawingCache = "none"
                 android:scrollbars = "none"
                 android:scrollingCache = "false"
                 android:smoothScrollbar = "true" 
             </ ListView >

ListView是一个经常要用到的android控件,现总结遇到过的一些美化的小细节。

1、listview在拖动的时候背景图片消失变成黑色背景,等到拖动完毕我们自己的背景图片才显示出来

解决:在XML中加入

android:scrollingCache=”false” 或 android:cacheColorHint=”#00000000″

2、listview的上边和下边有黑色的阴影

解决: android:fadingEdge=”none”

3、修改listview的Item默认选择时的黄色背景

解决:在java文件中使用listview.setSelector()方法,或使用如下代码

1
android:listSelector= "#00000000"//这样写是透明的,也可加入Drawable图片

4、lsitview的每一项之间需要设置一个图片做为间隔

解决: android:divider=”@drawable/list_driver”





listview 拖动 背景图 显隐    2013 - 07 -19

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
<!-- 最后一条item所在的位置会闪烁 -->
    
             < ListView
                 android:id = "@+id/recommand_app_list"
                 android:layout_width = "fill_parent"
                 android:layout_height = "fill_parent"
                 android:layout_below = "@id/recommands_list_view_header_divider"
                 android:fadingEdge = "none"
                 android:scrollbars = "none"
                 android:scrollingCache = "true" 
             </ ListView
    
    
    
<!--修复问题: 最后一条item所在的位置会闪烁 -->
    
             < ListView
                 android:id = "@+id/recommand_app_list"
                 android:layout_width = "fill_parent"
                 android:layout_height = "fill_parent"
                 android:layout_below = "@id/recommands_list_view_header_divider"
                 android:background = "@drawable/ic_content_bg_repeat"
                 android:divider = "@drawable/ic_list_divider_repeat"
                 android:dividerHeight = "1dp"
                 android:fadingEdge = "none"
                 android:persistentDrawingCache = "none"
                 android:scrollbars = "none"
                 android:scrollingCache = "false"
                 android:smoothScrollbar = "true" 
             </ ListView >

ListView是一个经常要用到的android控件,现总结遇到过的一些美化的小细节。

1、listview在拖动的时候背景图片消失变成黑色背景,等到拖动完毕我们自己的背景图片才显示出来

解决:在XML中加入

android:scrollingCache=”false” 或 android:cacheColorHint=”#00000000″

2、listview的上边和下边有黑色的阴影

解决: android:fadingEdge=”none”

3、修改listview的Item默认选择时的黄色背景

解决:在java文件中使用listview.setSelector()方法,或使用如下代码

1
android:listSelector= "#00000000"//这样写是透明的,也可加入Drawable图片

4、lsitview的每一项之间需要设置一个图片做为间隔

解决: android:divider=”@drawable/list_driver”

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值