title: Error line: Caused by: android.view.InflateException: Binary XML file line #19: Binary XML file line #10: Error inflating class
body: <p>I tried doing a Drawing application in my android studio but when I tried running it on my Phone or to the emulator. The app just suddenly stops.Here is the copy of my content_main activity xml file on Layout.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="#FFCCCCCC"
  android:orientation="vertical"
  tools:context=".MainActivity"&gt;
  
  &lt;com.example.chadymaebarinan.drawingview
      android:id="@+id/drawing"
      android:layout_width="fill_parent"
      android:layout_height="0dp"
      android:layout_marginBottom="3dp"
      android:layout_marginLeft="5dp"
      android:layout_marginRight="5dp"
      android:layout_marginTop="3dp"
      android:layout_weight="1"
      android:background="#FFFFFFFF" /&gt;
  
  &lt;LinearLayout
      android:layout_width="wrap_content"
      android:layout_height="50dp"
      android:layout_gravity="center"
      android:orientation="horizontal" &gt;
  
      &lt;ImageButton
          android:id="@+id/new_btn"
          android:layout_width="wrap_content"
          android:layout_height="fill_parent"
          android:contentDescription="@string/start_new"
          android:src="@drawable/new_pic" /&gt;
  
      &lt;ImageButton
          android:id="@+id/draw_btn"
          android:layout_width="wrap_content"
          android:layout_height="fill_parent"
          android:contentDescription="@string/brush"
          android:src="@drawable/brush" /&gt;
  
      &lt;ImageButton
          android:id="@+id/erase_btn"
          android:layout_width="wrap_content"
          android:layout_height="fill_parent"
          android:contentDescription="@string/erase"
          android:src="@drawable/eraser" /&gt;
  
      &lt;ImageButton
          android:id="@+id/save_btn"
          android:layout_width="wrap_content"
          android:layout_height="fill_parent"
          android:contentDescription="@string/save"
          android:src="@drawable/save" /&gt;
  &lt;/LinearLayout&gt;
  
  &lt;LinearLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:orientation="vertical"&gt;
  
      &lt;LinearLayout
          android:id="@+id/paint_colors"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:orientation="horizontal"&gt;
  
          &lt;ImageButton
              android:layout_width="@dimen/large_brush"
              android:layout_height="@dimen/large_brush"
              android:layout_margin="2dp"
              android:background="#FF660000"
              android:contentDescription="@string/paint"
              android:onClick="paintClicked"
              android:tag="#FF660000"
              android:src="@drawable/paint"/&gt;
  
          &lt;ImageButton
              android:layout_width="@dimen/large_brush"
              android:layout_height="@dimen/large_brush"
              android:layout_margin="2dp"
              android:background="#FFFF0000"
              android:contentDescription="@string/paint"
              android:onClick="paintClicked"
              android:src="@drawable/paint"
              android:tag="#FFFF0000" /&gt;
  
          &lt;ImageButton
              android:layout_width="@dimen/large_brush"
              android:layout_height="@dimen/large_brush"
              android:layout_margin="2dp"
              android:background="#FFFF6600"
              android:contentDescription="@string/paint"
              android:onClick="paintClicked"
              android:src="@drawable/paint"
              android:tag="#FFFF6600" /&gt;
  
          &lt;ImageButton
              android:layout_width="@dimen/large_brush"
              android:layout_height="@dimen/large_brush"
              android:layout_margin="2dp"
              android:background="#FFFFCC00"
              android:contentDescription="@string/paint"
              android:onClick="paintClicked"
              android:src="@drawable/paint"
              android:tag="#FFFFCC00" /&gt;
  
          &lt;ImageButton
              android:layout_width="@dimen/large_brush"
              android:layout_height="@dimen/large_brush"
              android:layout_margin="2dp"
              android:background="#FF009900"
              android:contentDescription="@string/paint"
              android:onClick="paintClicked"
              android:src="@drawable/paint"
              android:tag="#FF009900" /&gt;
  
          &lt;ImageButton
              android:layout_width="@dimen/large_brush"
              android:layout_height="@dimen/large_brush"
              android:layout_margin="2dp"
              android:background="#FF009999"
              android:contentDescription="@string/paint"
              android:onClick="paintClicked"
              android:src="@drawable/paint"
              android:tag="#FF009999" /&gt;
      &lt;/LinearLayout&gt;
      &lt;!-- Bottom Row --&gt;
      &lt;LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:orientation="horizontal" &gt;
  
          &lt;ImageButton
              android:layout_width="@dimen/large_brush"
              android:layout_height="@dimen/large_brush"
              android:layout_margin="2dp"
              android:background="#FF0000FF"
              android:contentDescription="@string/paint"
              android:onClick="paintClicked"
              android:src="@drawable/paint"
              android:tag="#FF0000FF" /&gt;
  
          &lt;ImageButton
              android:layout_width="@dimen/large_brush"
              android:layout_height="@dimen/large_brush"
              android:layout_margin="2dp"
              android:background="#FF990099"
              android:contentDescription="@string/paint"
              android:onClick="paintClicked"
              android:src="@drawable/paint"
              android:tag="#FF990099" /&gt;
  
          &lt;ImageButton
              android:layout_width="@dimen/large_brush"
              android:layout_height="@dimen/large_brush"
              android:layout_margin="2dp"
              android:background="#FFFF6666"
              android:contentDescription="@string/paint"
              android:onClick="paintClicked"
              android:src="@drawable/paint"
              android:tag="#FFFF6666" /&gt;
  
          &lt;ImageButton
              android:layout_width="@dimen/large_brush"
              android:layout_height="@dimen/large_brush"
              android:layout_margin="2dp"
              android:background="#FFFFFFFF"
              android:contentDescription="@string/paint"
              android:onClick="paintClicked"
              android:src="@drawable/paint"
              android:tag="#FFFFFFFF" /&gt;
  
          &lt;ImageButton
              android:layout_width="@dimen/large_brush"
              android:layout_height="@dimen/large_brush"
              android:layout_margin="2dp"
              android:background="#FF787878"
              android:contentDescription="@string/paint"
              android:onClick="paintClicked"
              android:src="@drawable/paint"
              android:tag="#FF787878" /&gt;
  
          &lt;ImageButton
              android:layout_width="@dimen/large_brush"
              android:layout_height="@dimen/large_brush"
              android:layout_margin="2dp"
              android:background="#FF000000"
              android:contentDescription="@string/paint"
              android:onClick="paintClicked"
              android:src="@drawable/paint"
              android:tag="#FF000000" /&gt;
      &lt;/LinearLayout&gt;
  
  
  &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Here is Full LogCat results when I tried to run the emulator</p>
  
  <pre><code>03-20 14:16:47.259 2807-2807/? I/art: Not late-enabling -Xcheck:jni (already     on)
  03-20 14:16:47.259 2807-2807/? I/art: Late-enabling JIT
  03-20 14:16:47.283 2807-2807/? I/art: JIT created with code_cache_capacity=2MB compile_threshold=1000
  03-20 14:16:47.315 2807-2814/? E/art: Failed sending reply to debugger: Broken pipe
  03-20 14:16:47.315 2807-2814/? I/art: Debugger is no longer active
  03-20 14:16:47.321 2807-2807/? W/System: ClassLoader referenced unknown path: /data/app/com.example.chadymaebarinan.drawingview-2/lib/x86
  03-20 14:16:47.355 2807-2807/? D/AndroidRuntime: Shutting down VM
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime: FATAL EXCEPTION: main
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime: Process:     com.example.chadymaebarinan.drawingview, PID: 2807
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime: java.lang.RuntimeException:         Unable to start activity                ComponentInfo{com.example.chadymaebarinan.drawingview/com.example.chadymaebarina    n.drawingview.MainActivity}: android.view.InflateException: Binary XML file     line #19: Binary XML file line #10: Error inflating class     com.example.chadymaebarinan.drawingview
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread.-wrap11(ActivityThread.java)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:148)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5417)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at     java.lang.reflect.Method.invoke(Native Method)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:  Caused by: android.view.InflateException: Binary XML file line #19: Binary XML file line     #10: Error inflating class com.example.chadymaebarinan.drawingview
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:257)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at com.example.chadymaebarinan.drawingview.MainActivity.onCreate(MainActivity.java:28)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.Activity.performCreate(Activity.java:6237)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread.-wrap11(ActivityThread.java) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:148) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5417) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:  Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class com.example.chadymaebarinan.drawingview
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at     android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:971)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:831)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:257) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at com.example.chadymaebarinan.drawingview.MainActivity.onCreate(MainActivity.java:28) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.Activity.performCreate(Activity.java:6237) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread.-wrap11(ActivityThread.java) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:148) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5417) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:  Caused by:     java.lang.ClassNotFoundException: Didn't find class     "com.example.chadymaebarinan.drawingview" on path: DexPathList[[zip file     "/data/app/com.example.chadymaebarinan.drawingview-    2/base.apk"],nativeLibraryDirectories=    [/data/app/com.example.chadymaebarinan.drawingview-2/lib/x86, /vendor/lib, /system/lib]]
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.createView(LayoutInflater.java:583)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:971) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:831) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at     android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:257) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at com.example.chadymaebarinan.drawingview.MainActivity.onCreate(MainActivity.java:28) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.Activity.performCreate(Activity.java:6237) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread.-wrap11(ActivityThread.java) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:148) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5417) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:    Suppressed: java.lang.ClassNotFoundException: com.example.chadymaebarinan.drawingview
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at java.lang.Class.classForName(Native Method)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:     at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:            ... 27 more
  03-20 14:16:47.355 2807-2807/? E/AndroidRuntime:  Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
  03-20 14:16:50.535 2807-2807/? I/Process: Sending signal. PID: 2807 SIG: 9
  </code></pre>
  
  <p>Have no Idea, how to fix this code. I think it has something to do with my layout file.</p>
  
  <pre><code>&lt;com.example.chadymaebarinan.drawingview
      android:id="@+id/drawing"
      android:layout_width="fill_parent"
      android:layout_height="0dp"
      android:layout_marginBottom="3dp"
      android:layout_marginLeft="5dp"
      android:layout_marginRight="5dp"
      android:layout_marginTop="3dp"
      android:layout_weight="1"
      android:background="#FFFFFFFF" /&gt;
  </code></pre>
  
  <p>But I don't know :( Please tell me how to fix the errors. Thank you so much!</p>
  
  <p>Update: Here is my drawingview class</p>
  
  <p>package com.example.chadymaebarinan.drawingview;</p>
  
  <pre><code>import android.content.Context;
  import android.graphics.Color;
  import android.util.AttributeSet;
  import android.view.View;
  import android.graphics.Bitmap;
  import android.graphics.Canvas;
  import android.graphics.Paint;
  import android.graphics.Path;
  import android.view.MotionEvent;
  
  public class DrawingView extends View {
  private Path drawPath;
  //drawing and canvas paint
  private Paint drawPaint, canvasPaint;
  //initial color
  private int paintColor = 0xFF660000;
  //canvas
  private Canvas drawCanvas;
  //canvas bitmap
  private Bitmap canvasBitmap;
  public DrawingView(Context context, AttributeSet attrs){
      super(context, attrs);
      setupDrawing();
  }
  
  private void setupDrawing(){
      drawPath = new Path();
      drawPaint = new Paint();
      drawPaint.setColor(paintColor);
      drawPaint.setAntiAlias(true);
      drawPaint.setStrokeWidth(20);
      drawPaint.setStyle(Paint.Style.STROKE);
      drawPaint.setStrokeJoin(Paint.Join.ROUND);
      drawPaint.setStrokeCap(Paint.Cap.ROUND);
      canvasPaint = new Paint(Paint.DITHER_FLAG);
  //get drawing area setup for interaction
  }
  
  @Override
  protected void onSizeChanged(int w, int h, int oldw, int oldh) {
  //view given size
      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);
      canvas.drawPath(drawPath, drawPaint);
  //draw view
  }
  
  @Override
  public boolean onTouchEvent(MotionEvent event) {
  //detect user touch
      float touchX = event.getX();
      float touchY = event.getY();
  
      switch (event.getAction()) {
          case MotionEvent.ACTION_DOWN:
              drawPath.moveTo(touchX, touchY);
              break;
          case MotionEvent.ACTION_MOVE:
              drawPath.lineTo(touchX, touchY);
              break;
          case MotionEvent.ACTION_UP:
              drawCanvas.drawPath(drawPath, drawPaint);
              drawPath.reset();
              break;
          default:
              return false;
  
      }
  
      invalidate();
      return true;
  }
  
  public void setColor(String newColor){
      invalidate();
      paintColor = Color.parseColor(newColor);
      drawPaint.setColor(paintColor);
  //set color
  }
  }
  </code></pre>