0

I have ImageView with shape but image is also visible to the outside of shape bounds. This is my shape code:

  <?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/dashboard_bg" />
    <item>
        <shape xmlns:android="http://schemas.android.com/apk/res/android"
            android:innerRadius="0dp"
            android:shape="ring"
            android:thicknessRatio="1.9"
            android:useLevel="false">
            <solid android:color="@android:color/transparent" />
            <padding
                android:bottom="7dp"
                android:left="7dp"
                android:right="7dp"
                android:top="7dp" />
            <stroke
                android:width="10dp"
                android:color="@android:color/white" />
        </shape>
    </item>
</layer-list>

and this is my ImageView

<ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/layer_list_circl"/>

And this is the result i got..
Please see this result image i got

what i want just squeeze image into shape. Thanks in advance.

ColdFire
  • 6,764
  • 6
  • 35
  • 51

2 Answers2

0

First of all, the image you are loading seems large, so you need to scale it to fit the right size you want. since the image you are trying to wrap is rectangle it can't be wrapped in a ring shape.

Therefore, you can use an image loading lib like fresco or picasso and set the correct size you want, and the scaling/crop option. After you did that, you can add the background as you created and it should fit the image.

Oren Zakay
  • 519
  • 8
  • 17
0

You can try adding this to your ImageView:

<ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scaleType="fitXY"
        android:src="@drawable/layer_list_circl"/>