1

I'm working on Android API-14

I want to make circle bitmap and draw border. I write this code;

public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(output);
    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(),
            bitmap.getHeight());

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 100);
    // paint.setColor(color);
    canvas.drawCircle(bitmap.getWidth() / 2,
            bitmap.getHeight() / 2, bitmap.getWidth() / 2, paint);
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));

    paint.setColor(Color.WHITE);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth((float) 50);

    canvas.drawBitmap(bitmap, rect, rect, paint);

    return output;

    }

But it can only be a bitmap circle. But I couldn't draw a border around it. How can i solve this problem? Thanks.

Jay Snayder
  • 4,298
  • 4
  • 27
  • 53
  • Api 14 is almost dead. Almost all the users have upgraded to API 15 (4.0.3). You can check this at https://developer.android.com/about/dashboards/index.html. Second, in order to answer your question, you should check some external library like https://github.com/Pkmmte/CircularImageView or https://github.com/vinc3m1/RoundedImageView. – Luciano Rodríguez Jan 20 '15 at 21:39

0 Answers0