1

I am using Piccaso library for circular image but somehow i am not able to add red circular border aound image. I am using below Tranform class to do it:

ublic class RedCircleTransform implements Transformation {
        int mBorderSize;

        @Override
        public Bitmap transform(Bitmap source) {
            int size = Math.min(source.getWidth(), source.getHeight());

            int x = (source.getWidth() - size) / 2;
            int y = (source.getHeight() - size) / 2;

            Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
            if (squaredBitmap != source) {
                source.recycle();
            }

            Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);

            Canvas canvas = new Canvas(bitmap);
            Paint paint = new Paint();
            BitmapShader shader = new BitmapShader(squaredBitmap,
                    BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
            paint.setShader(shader);
        paint.setStrokeWidth(10);
            paint.setColor(Color.RED);
            paint.setAntiAlias(true);

            float r = size / 2f;
            canvas.drawCircle(r, r, r, paint);

            squaredBitmap.recycle();
            return bitmap;
        }

        @Override
        public String key() {
            return "circle";
        }
}

2 Answers2

2

You can use CircularImageView by Lopez Mikhael

GRADLE

compile 'com.mikhaellopez:circularimageview:3.0.2'

XML

<com.mikhaellopez.circularimageview.CircularImageView
        android:layout_width="250dp"
        android:layout_height="250dp"
        android:src="@drawable/image"
        app:civ_border_color="#EEEEEE"
        app:civ_border_width="4dp"
        app:civ_shadow="true"
        app:civ_shadow_radius="10"
        app:civ_shadow_color="#8BC34A"/>
General Grievance
  • 4,555
  • 31
  • 31
  • 45
Harsh Singhal
  • 567
  • 4
  • 12
0

Use this dependency for circular image view and it includes other types of image view also.

Add this line to your dependency

compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'

And in XML

<com.github.siyamed.shapeimageview.CircularImageView
        android:id="@+id/android_gridview_image"
        android:layout_width="75dp"
        android:layout_height="65dp"
        app:siBorderColor="#fff"
        android:layout_marginTop="15dp" />
Pang
  • 9,564
  • 146
  • 81
  • 122