I have a Imageview set with a white background and 1dp padding, this creates a border-like effect, which is the wanted result.
Now if I set the scaleType to centerCrop it ignores the padding on the top and bottom.
So I still have my border on the left and right side, but not on the top and bottom.
Anyone with an idea to stop this from happening? Or another quick way to create a border around images. I use it for my custom gridview
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#FFFFFF"
android:contentDescription="@string/test"
android:padding="1dp"
android:src="@drawable/some_photo"
android:scaleType="centerCrop" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:contentDescription="@string/test"
android:padding="1dp"
android:src="@drawable/some_photo"
android:cropToPadding="true"
android:scaleType="centerCrop" />
You only need to add android:cropToPadding
android:cropToPadding="true"
and then the imageView is going to respect the padding that you choose.