I am using ShapeableImageView
thus:
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/myImage"
android:layout_width="200dp"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:src="@drawable/larry"
app:strokeColor="@color/red"
app:strokeWidth="9dp"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.App.CornerCircle" />
and it's drawing quite alright. However, I want a little spacing between the view and the stroke. I have tried android:padding="10dp"
but that doesn't seem to be working.
I have also tried removing the stroke properties and using this drawable resource to set the background of the view:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke
android:width="9dp"
android:color="#00FF00" />
</shape>
but the border didn't appear at all.
Please, do you know of any way I can achieve it?
I was looking for this myself, and just stumbled on
contentPadding
in the Android documentation.In XML:
In code: