title: Why are buttons making my canvas drawing like hexagon shape in Android?
body: <p><a href="https://i.stack.imgur.com/omp5C.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/omp5C.jpg" alt="Smooth circle"></a>  <a href="https://i.stack.imgur.com/gNtnZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gNtnZ.jpg" alt="enter image description here"></a>I have a strange problem I'm creating a canvas drawing app in Android that has lots of buttons in xml file.  The problems is  when I draw a circle with all those buttons included in the file it's never a smooth circle it's full of corners like hexagon shape but when I exclude buttons may be leaving in one or two, it draws a perfect smooth circle. I have tried to split the file into three so I've included them using  but still same result. Can someone please enlighten me what am I do wrong.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".MainActivity"&gt;
  
  &lt;!--First Draw --&gt;
  &lt;android.support.v4.widget.DrawerLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/drawer_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:openDrawer="start"&gt;
  
      &lt;LinearLayout
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical" &gt;
  
          &lt;ImageButton
              android:id="@+id/nav_one"
              android:layout_width="30dp"
              android:layout_height="60dp"
              android:layout_marginTop="100dp"
              android:layout_marginBottom="100dp"
              android:background="@drawable/ic_tab_res_bkg"/&gt;
          &lt;ImageButton
              android:id="@+id/nav_two"
              android:layout_width="30dp"
              android:layout_height="60dp"
              android:layout_marginTop="200dp"
              android:background="@drawable/ic_tab_tools_bkg"/&gt;
      &lt;/LinearLayout&gt;
  
      &lt;FrameLayout
          android:id="@+id/content_frame"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  
     &lt;!-- The navigation drawer --&gt;
  
     &lt;ListView android:id="@+id/resource_bank"
          android:layout_width="350dp"
          android:layout_height="match_parent"
          android:layout_gravity="start"
          android:choiceMode="singleChoice"
          android:divider="@android:color/background_light"
          android:dividerHeight="0dp"
          android:background="#f4f1f1"
          /&gt;
      &lt;ListView android:id="@+id/tools"
          android:layout_width="350dp"
          android:layout_height="match_parent"
          android:layout_gravity="end"
          android:choiceMode="singleChoice"
          android:divider="@android:color/background_light"
          android:dividerHeight="0dp"
          android:background="#dedada"/&gt;
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  
  &lt;RelativeLayout
      android:id="@+id/main"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_gravity="center" &gt;
  
      &lt;xxxxx.xxxxxx.xxxx.xxxxxx.DrawView
          android:id="@+id/canvas_view"
          android:layout_width="match_parent"
          android:layout_height="match_parent"/&gt;
  
      &lt;FrameLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignBottom="@+id/canvas_view"&gt;
  
          &lt;!-- Pen icons --&gt;
  
      &lt;include  layout="@layout/activity_pen_color" android:id="@+id/pen_color" /&gt;
      &lt;include layout="@layout/activity_pen_style"  android:id="@+id/pen_style" /&gt;
  
          &lt;!--  Navigation bar icons  --&gt;
  
          &lt;ImageView
              android:id="@+id/icon_bar"
              android:layout_width="match_parent"
              android:layout_height="70dp"
              android:layout_gravity="bottom"
              android:background="@drawable/icon_bar_bkg"
              /&gt;
          &lt;Button
              android:id="@+id/ic_select"
              android:layout_width="30dp"
              android:layout_height="30dp"
              android:layout_marginLeft="150dp"
              android:layout_marginTop="60dp"
              android:elevation="1dp"
              android:background="@drawable/ic_select_bkg"/&gt;
          &lt;TextView
              android:id="@+id/text_select"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginLeft="150dp"
              android:layout_marginTop="90dp"
              android:text="Select"
              android:textColor="@color/colorAccent"
              /&gt;
          &lt;Button
              android:id="@+id/ic_pens"
              android:layout_width="30dp"
              android:layout_height="30dp"
              android:layout_marginLeft="200dp"
              android:layout_marginTop="60dp"
              android:elevation="1dp"
              android:background="@drawable/ic_pen_bkg"/&gt;
          &lt;TextView
              android:id="@+id/text_pens"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginLeft="200dp"
              android:layout_marginTop="90dp"
              android:text="Pen"
              android:textColor="@color/colorAccent"
              /&gt;
      &lt;/FrameLayout&gt;
    &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>My DrawView</p>
  
  <pre><code>public class DrawView extends View {
  
  private Paint drawPaint, canvasPaint;
  private Canvas drawCanvas;
  private Bitmap canvasBitmap;
  
  private SparseArray&lt;Path&gt; paths;
  
  public DrawView(Context context) {
      super(context);
      setupDrawing();
  }
  
  public DrawView(Context context, AttributeSet attrs) {
      super(context, attrs);
      setupDrawing();
  }
  
  public DrawView(Context context, AttributeSet attrs, int defStyleAttr) {
      super(context, attrs, defStyleAttr);
      setupDrawing();
  }
  
  private void setupDrawing() {
      paths = new SparseArray&lt;&gt;();
  
      drawPaint = new Paint();
      drawPaint.setColor(Color.BLACK);
      drawPaint.setAntiAlias(true);
      drawPaint.setStrokeWidth(9);
      drawPaint.setStyle(Paint.Style.STROKE);
      drawPaint.setStrokeJoin(Paint.Join.ROUND);
      drawPaint.setStrokeCap(Paint.Cap.ROUND);
  
      canvasPaint = new Paint(Paint.DITHER_FLAG);
  }
  
  @Override
  protected void onSizeChanged(int w, int h, int oldw, int oldh) {
      super.onSizeChanged(w, h, oldw, oldh);
      canvasBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
      drawCanvas = new Canvas(canvasBitmap);
  }
  
  @Override
  protected void onDraw(Canvas canvas) {
      canvas.drawBitmap(canvasBitmap, 0, 0, canvasPaint);
      for (int i=0; i&lt;paths.size(); i++) {
          canvas.drawPath(paths.valueAt(i), drawPaint);
      }
  }
  
  @Override
  public boolean onTouchEvent(MotionEvent event) {
      int index = event.getActionIndex();
      int id = event.getPointerId(index);
  
      Path path;
      switch (event.getActionMasked()) {
          case MotionEvent.ACTION_DOWN:
          case MotionEvent.ACTION_POINTER_DOWN:
              path = new Path();
              path.moveTo(event.getX(index), event.getY(index));
              paths.put(id, path);
              break;
  
          case MotionEvent.ACTION_MOVE:
              for (int i=0; i&lt;event.getPointerCount(); i++) {
                  id = event.getPointerId(i);
                  path = paths.get(id);
                  if (path != null) path.lineTo(event.getX(i), event.getY(i));
              }
              break;
  
          case MotionEvent.ACTION_UP:
          case MotionEvent.ACTION_POINTER_UP:
              path = paths.get(id);
              if (path != null) {
                  drawCanvas.drawPath(path, drawPaint);
                  paths.remove(id);
              }
              break;
          default:
              return false;
      }
      invalidate();
      return true;
  }
  
  /**
   * change path color here
   */
  public void setPathColor(int color) {
      drawPaint.setColor(color);
   }
  }
  </code></pre>