Android Images with Rounded Corners : ImageView


Just like Buttons, we can make Android ImageView's have rounded corners using an Android XML file.

Example: image_rounded.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <corners
        android:bottomLeftRadius="30dp"
        android:bottomRightRadius="30dp"
        android:radius="30dp"
        android:topLeftRadius="30dp"
        android:topRightRadius="30dp" />

</shape>
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.code2care.example.MainActivity"
    tools:ignore="HardcodedText" >

    <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="72dp"
        android:layout_marginTop="82dp"
        android:background="@drawable/image_rounded"
        android:src="@drawable/mona" />

</RelativeLayout>