1

Im using Picasso and trying to put image in circle imageview, but the picture is still square. How can i fix it ?

  Picasso.with(context).load(resId).resizeDimen(R.dimen.image_size, R.dimen.image_size).into(holder.mImageViewItem);

image_size = 60dp

drawable resource :

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#FFF"/>

and imageview :

   <ImageView
    android:id="@+id/picture_imageview_item"
    android:layout_marginTop="15dp"
    android:layout_marginLeft="25dp"
    android:layout_marginBottom="15dp"
    android:layout_width="60dp"
    android:layout_height="60dp"
    android:background="@drawable/buttonshape" />

2 Answers2

0

You can make a simple circle with white border and transparent content with shape.

// res/drawable/circle.xml

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

    <stroke
        android:width="10dp"
        android:color="@android:color/white" />
</shape>

Then make a layerlist drawable and put it as background to your imageview.

// res/drawable/img.xml

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

        <item android:drawable="@drawable/ic_launcher"/>
        <item android:drawable="@drawable/circle"/>

    </layer-list>

and put it as background to your imageview.

<ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/img"/>

In place of ic_launcher, you can add your image. Thanks !!

0

There are different libraries you can use for a circle shaped image. The best one which i came across is

Siyamed

Manny
  • 1
  • 1