Border around an ImageView

Recently I had to add a border around an ImageView. Basically I was loading the image from an url using UniversalImageLoader but I set the scaleType of the view to be fitCenter. This type of scaling was causing an additional padding around the ImageView causing the border to look very ugly.

 The solution was to change the scale type, add the two options below and the border would fit perfectly in the ImageView. 🙂

<item name="android:scaleType">centerCrop</item>

<item name="android:cropToPadding">true</item>

<item name="android:adjustViewBounds">true</item>

You may also like...