title: Programmatically set radius for squares
body: <p>I'm design any squares in custom layout extends <code>ImageView</code> but I can not find any document about how to set radius or round squares my squares is like with this:</p>
  
  <p><img src="https://i.stack.imgur.com/GdeDG.png" alt="enter image description here"></p>
  
  <p>but I need like with this:</p>
  
  <p><img src="https://i.stack.imgur.com/zx5hL.png" alt="enter image description here"></p>
  
  <p>My code:</p>
  
  <pre><code>public class GameView extends ImageView {
      private Paint paint;
      private Paint textPaint;
      private int with;
      private int height;
      private int[][] cells = new int[4][4];
      public GameView(Context context) {
          super(context);
          initialize();
      }
  
      public GameView(Context context, AttributeSet attrs) {
          super(context, attrs);
          initialize();
      }
  
      public GameView(Context context, AttributeSet attrs, int defStyle) {
          super(context, attrs, defStyle);
          initialize();
      }
  
      public void initialize(){
          paint = new Paint();
          paint.setColor(Color.parseColor("#afafaf"));
          paint.setStyle(Paint.Style.FILL_AND_STROKE);
          paint.setAntiAlias(true);
  
      }
  
      @Override
      protected void onDraw(Canvas canvas) {
          super.onDraw(canvas);
          int size = with / 4;
          int padding = 5;
          for ( int i=0; i &lt; 4 ; i++)
          {
              for( int j=0; j &lt; 4 ; j++){
                  Rect rect = new Rect( i*size + padding , j*size + padding , (i+1) *size - padding, (j+1)*size - padding );
                  canvas.drawRect(rect, paint);
              }
          }
      }
  }
  </code></pre>