Android之ListView中的分割线和行高

http://blog.csdn.net/way_ping_li/article/details/8037558


ListView中每个Item项之间都有分割线,设置android:footerDividersEnabled表示是否显示分割线,此属性默认为true。

1.不显示分割线只要在ListView控件中添加android:footerDividersEnabled="false"即可。

[html]  view plain copy
  1. <ListView  
  2.     android:id="@+id/local_groups_list"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="wrap_content"  
  5.     android:footerDividersEnabled="false" />  


 

2.改变ListView的分割线颜色和宽度,需要在布局中定义android:dividerandroid:dividerHeight属性。

[html]  view plain copy
  1. <ListView  
  2.     android:id="@+id/local_groups_list"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="wrap_content"  
  5.     android:divider="@color/divider_color"  
  6.     android:dividerHeight="1px" />  

调整ListView分割线

主要用以下2个属性来调整

android:divider="@drawable/line" 可以是图片可以是颜色

android:dividerHeight="3px"  数量单位

调整ListView行高

主要是调整adapter包含的layout的行高


main_list代码是:


[java]  view plain copy
  1. SimpleAdapter adapter = new SimpleAdapter(this,getData(),R.layout.main_list,  
  2.   
  3. new String[]{"img""info"},  

main_list.xml代码是:

[html]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2.   
  3. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  4.   
  5.     android:orientation="horizontal"   
  6.   
  7.     android:layout_width="fill_parent"  
  8.   
  9.     android:layout_height="70dip"  
  10.   
  11.     android:gravity="center"  
  12.   
  13.     >  
  14.   
  15.     <ImageView android:id="@+id/img"  
  16.   
  17.         android:layout_width="wrap_content"  
  18.   
  19.         android:layout_height="wrap_content"  
  20.   
  21.         android:paddingTop="5px"  
  22.   
  23.         android:paddingBottom="5px"  
  24.   
  25.         />  
  26.   
  27.    
  28.   
  29.     <TextView android:id="@+id/info"  
  30.   
  31.      android:layout_width="wrap_content"  
  32.   
  33.         android:layout_height="wrap_content"  
  34.   
  35.         android:textSize="20sp"  
  36.   
  37.      />  
  38.   
  39. </LinearLayout>  

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值