概览
l 目的
l 方法
l 具体实现
l 注意事项
l 效果
目的
原生的ListView出来的效果显然太平淡了,大多应用开始使用圆角ListView来增添用界面的
美感。本文的目的是实现ListView圆角。
方法
论坛上基本上是两种实现方式。一种是shape实现,另一种是9.png图片实现。根据自己喜
好选择哪种方式实现
具体实现
本文采用shape 方式实现。
l 圆角背景list_corner_round_bg..xml
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="" android:shape="rectangle"><!– 渐变 –><gradient android:angle="180" android:endColor="#FFCCCCCC"android:startColor="@android:color/white" /><!– 描边 –><stroke android:width="1dp" android:color="@color/color_gray" /><!– 实心填充 –><solid android:color="@color/color_white" /><!– 圆角 –><corners android:bottomLeftRadius="8dip"android:bottomRightRadius="8dip" android:topLeftRadius="8dip"android:topRightRadius="8dip" /></shape>
l List第一项背景 list_corner_round_top.xml
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="" ><!–渐变<gradient android:startColor="#B5E7B8"android:endColor="#76D37B"android:angle="270"/>–><gradientandroid:angle="270"android:endColor="#40B9FF"android:startColor="#BFEEFF" /><cornersandroid:topLeftRadius="8dip"android:topRightRadius="8dip" /></shape>
l List中间项背景list_corner_round_mid.xml
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="" ><!–渐变<gradient android:startColor="#B5E7B8"android:endColor="#76D37B"android:angle="270"/>–><gradientandroid:angle="270"android:endColor="#40B9FF"android:startColor="#BFEEFF" /></shape>
l List最后项背景 list_corner_round_bottom.xml
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="" ><!–渐变<gradient android:startColor="#B5E7B8"android:endColor="#76D37B"android:angle="270"/>–><gradientandroid:angle="270"android:endColor="#40B9FF"android:startColor="#BFEEFF" /><cornersandroid:bottomLeftRadius="8dip"android:bottomRightRadius="8dip" /></shape>
德高培身,财多伤身。