To draw a square I use the replacement ImageView on the drawn Circle (Rectangle) .
Here is my code for creating an ImageView and drawing a circle:
imageView = new ImageView(getApplicationContext()); imageView.setId(R.id.imageViewCircle); imageView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); ((RelativeLayout)swipe).addView(imageView); ImageView imageView=(ImageView) findViewById(R.id.imageViewCircle); bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); canvas = new Canvas(bitmap); paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.BLACK); canvas.drawCircle(50, 50, 40, paint); imageView.setImageBitmap(bitmap); That's what comes out for me:
(See Screenshot)