I’ve found several solutions on how to do this through the activity but I’d much rather stick to using xml for layout and graphics.
I want to set an image on a button with rounded edges instead of the plain default corners.
XML SAMPLE:
<ImageView
android:id="@+id/featuredimage"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:clickable="true"
android:background="@drawable/rounded"
android:src="@drawable/budlight_sample"
android:scaleType="centerCrop" />
ROUNDED.XML
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp" >
</corners>
</shape>
Use shape drawable for rounded corners , define a rounded.xml in drawable folder of your app.
ref: http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape
In your layout.xml file use the the rounded.xml as background for your view.