ListViews are, generally, pretty boring. If we’re displaying some kind of image-based data, we can bind ImageViews into them – and to make them slightly prettier, round off the top/bottom edges of the list. This works especially well with subheaded-lists.

To do this, I grabbed some code from that rounds all edges of a bitmap and modified it.

public Bitmap getRoundedCornerBitmap(Bitmap bitmap) 
	final int color = 0xff424242;
	final Paint paint = new Paint();
	final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
	Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
	Canvas canvas = new Canvas(output);

	// the float array passed to this function defines the x/y values of the corners
	// it starts top-left and works clockwise
	// so top-left-x, top-left-y, top-right-x etc
	// a curve of 10.0f will typically work pretty well for a larger image
	RoundRectShape rrs = new RoundRectShape(
			new float[] {0, 0, 0, 0, 0, 0, 0, 0}, 
						null, null);
	canvas.drawARGB(0, 0, 0, 0);
	rrs.resize(bitmap.getWidth(), bitmap.getHeight());
	rrs.draw(canvas, paint);
	paint.setXfermode(new PorterDuffXfermode(;
	canvas.drawBitmap(bitmap, rect, rect, paint);
	return output;

With this, we can do something like the below.

private List<something> mData;

public SomeAdapter(...)
	mData = data;

public View getView(int position, View convertView, ViewGroup parent)
	ViewHolder holder;
	if (convertView == null)
		// ...
		// ...
	// get Bitmap b from a file or somewhere (it's our image for this list item)
	// i modified the function again to be 0 = top edges rounded
	if (position == 0)
		b = getRoundedCornerBitmap(b, 0);

	// no else, our item could be the only one in its list and hence may need rounding on both edges

	if (position == mData.size() - 1)
		b = getRoundedCornerBitmap(b, 1); // and 1 is bottom