how to draw a circle on Canvas using java for android

Viewed 19815

I want to draw a circle on a canvas in my android app. I searched a lot and realized if I need a dynamic form of painting which can be updated time by time I need to use canvas instead of imageView.

any help is appreciated

this is the code that I wrote so far but it will not draw anything on the android device screen:

    private void createBitMap() {
    Bitmap bitMap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);  //creates bmp
    bitMap = bitMap.copy(bitMap.getConfig(), true);     //lets bmp to be mutable
    Canvas canvas = new Canvas(bitMap);                 //draw a canvas in defined bmp

    Paint paint = new Paint();                          //define paint and paint color
    paint.setColor(Color.RED);
    paint.setStyle(Style.FILL_AND_STROKE);
    //paint.setAntiAlias(true);

    canvas.drawCircle(50, 50, 10, paint);
}
2 Answers
Related