Android自定义ListView的分割线_自定义选中效果_选中颜色色
2014-09-15 14:50:38 By: shinyuu
今天做项目的时候、设计到了设置 ListView 的样子、主要设计到设置分割线样子和选中的颜色
下面我把我今天遇到的情况以及解释办法记录下来、便于以后查阅、同时也可以帮助一些相同需求的哥们
话不多说、下面进入正题
一、不显示ListView的分割线
ListView中每个Item项之间都有分割线、设置android:footerDividersEnabled表示是否显示分割线
此属性默认为true、如果不想显示可设为false、这样分割线就不会显示了
不显示分割线只要在ListView控件中添加android:footerDividersEnabled="false"即可
<ListView android:id="@+id/local_groups_list" android:layout_width="match_parent" android:layout_height="wrap_content" android:footerDividersEnabled="false" />
二、改变ListView的分割线颜色、需要在布局中定义android:divider属性
<ListView android:layout_width="match_parent" android:layout_height="match_parent" android:divider="@color/common_division_line" android:footerDividersEnabled="true" />
三、改变ListView的分割线宽度、需要在布局中定义android:dividerHeight属性
<ListView android:layout_width="match_parent" android:layout_height="wrap_content" android:dividerHeight="1px" />
四、自定义ListView选中效果、设置android:listSelector="@color/common_grey"属性
<ListView android:layout_width="match_parent" android:layout_height="match_parent" android:listSelector="@color/common_grey" android:footerDividersEnabled="true" />
好了、这样一个简单的ListView自定义效果就实现了、希望对大家有帮助
若资源对你有帮助、浏览后有很大收获、不妨小额打赏我一下、你的鼓励是维持我不断写博客最大动力
想获取DD博客最新代码、你可以扫描下方的二维码、关注DD博客微信公众号(ddblogs)
或者你也可以关注我的新浪微博、了解DD博客的最新动态:DD博客官方微博(dwtedx的微博)
如对资源有任何疑问或觉得仍然有很大的改善空间、可以对该博文进行评论、希望不吝赐教
为保证及时回复、可以使用博客留言板给我留言: DD博客留言板(dwtedx的留言板)
感谢你的访问、祝你生活愉快、工作顺心、欢迎常来逛逛