ImageView ScaleType ignores padding

android, border, gridview, imageview

Solution

I just encountered the same problem, for my workaround will be adding the android:layout_marginRight="5dip"

<ImageView
    android:layout_width="40dp"
    android:layout_height="30dp"
    android:background="#ffffffff"
    android:src="@drawable/liveview_logo"
    android:layout_marginRight="5dip"/>

Problem

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" /> ```

Original source

Related problems