Border for an Image view in Android?

Praveen picture Praveen · Jul 16, 2010 · Viewed 296.6k times · Source

How can I set a border for an ImageView and change its color in Android?

Answer

Praveen picture Praveen · Jul 16, 2010

I set the below xml to the background of the Image View as Drawable. It works.

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#FFFFFF" />
    <stroke android:width="1dp" android:color="#000000" />
    <padding android:left="1dp" android:top="1dp" android:right="1dp"
        android:bottom="1dp" />
</shape>

And then add android:background="@drawable/yourXmlFileName" to your ImageView