I wrote this article and was inspired by the blog post published by kiritor's column on Android UI controls to achieve the rounded Corner Effect of listview.
First look:
First, you have to write a class named cornerlistview.
/*** Rounded listview example ** @ Description: rounded listview example * @ filename: cornerlistview. java */public class cornerlistview extends listview {public cornerlistview (context) {super (context);} public cornerlistview (context, attributeset attrs, int defstyle) {super (context, attrs, defstyle);} public cornerlistview (context, attributeset attrs) {super (context, attrs);} @ override public Boolean onintercepttouchevent (motionevent eV) {Switch (ev. getaction () {Case motionevent. action_down: int x = (INT) eV. getx (); int y = (INT) eV. gety (); int itemnum = pointtoposition (x, y); If (itemnum = adapterview. invalid_position) break; else {If (itemnum = 0) {If (itemnum = (getadapter (). getcount ()-1) {setselector (R. drawable. app_list_corner_round);} else {setselector (R. drawable. app_list_corner_round_top) ;}} else if (itemnum = (getadapter (). getcount ()-1) setselector (R. drawable. app_list_corner_round_bottom); else {setselector (R. drawable. app_list_corner_shape) ;}} break; Case motionevent. action_up: break;} return Super. onintercepttouchevent (EV );}}
App_list_corner_round
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#BFEEFF" android:endColor="#40B9FF" android:angle="270"/> <corners android:topLeftRadius="6dip" android:topRightRadius="6dip" android:bottomLeftRadius="6dip" android:bottomRightRadius="6dip"/></shape>
App_list_corner_round_top
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#BFEEFF" android:endColor="#40B9FF" android:angle="270"/> <corners android:topLeftRadius="6dip" android:topRightRadius="6dip"/></shape>
App_list_corner_round_bottom
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#BFEEFF" android:endColor="#40B9FF" android:angle="270"/> <corners android:bottomLeftRadius="6dip" android:bottomRightRadius="6dip" /></shape>
App_list_corner_shape
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#BFEEFF" android:endColor="#40B9FF" android:angle="270"/></shape>
After writing it, You can directly call it in your code like listview.