title: Binary XML file line #0: Error inflating class
body: <p>My application stop and I ge Binary XML file error on line #0. It`s kinda weird, because I didn't see problem like this with line 0, so I need your help, everyone. Thanks!
  This Works Fine On API greater than 20 only lower than API devices is crashing the application</p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
                Process: com.example.vickyy.iwasframed, PID: 7818
                java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.vickyy.iwasframed/com.example.vickyy.iwasframed.ImageSize}: android.view.InflateException: Binary XML file line #0: Error inflating class com.example.vickyy.iwasframed.CustomFrame
                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
                    at android.app.ActivityThread.access$900(ActivityThread.java:161)
                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
                    at android.os.Handler.dispatchMessage(Handler.java:102)
                    at android.os.Looper.loop(Looper.java:157)
                    at android.app.ActivityThread.main(ActivityThread.java:5356)
                    at java.lang.reflect.Method.invokeNative(Native Method)
                    at java.lang.reflect.Method.invoke(Method.java:515)
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
                    at dalvik.system.NativeStart.main(Native Method)
                 Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.example.vickyy.iwasframed.CustomFrame
                    at android.view.LayoutInflater.createView(LayoutInflater.java:609)
                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
                    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
                    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
                    at com.example.vickyy.iwasframed.ImageSize.onCreate(ImageSize.java:31)
                    at android.app.Activity.performCreate(Activity.java:5426)
                    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363) 
                    at android.app.ActivityThread.access$900(ActivityThread.java:161) 
                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265) 
                    at android.os.Handler.dispatchMessage(Handler.java:102) 
                    at android.os.Looper.loop(Looper.java:157) 
                    at android.app.ActivityThread.main(ActivityThread.java:5356) 
                    at java.lang.reflect.Method.invokeNative(Native Method) 
                    at java.lang.reflect.Method.invoke(Method.java:515) 
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265) 
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081) 
                    at dalvik.system.NativeStart.main(Native Method) 
                 Caused by: java.lang.NoSuchMethodException: &lt;init&gt; [class android.content.Context, interface android.util.AttributeSet]
                    at java.lang.Class.getConstructorOrMethod(Class.java:472)
                    at java.lang.Class.getConstructor(Class.java:446)
                    at android.view.LayoutInflater.createView(LayoutInflater.java:574)
                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702) 
                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) 
                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:354) 
                    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
                    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
                    at com.example.vickyy.iwasframed.ImageSize.onCreate(ImageSize.java:31) 
                    at android.app.Activity.performCreate(Activity.java:5426) 
                    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) 
                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269) 
                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363) 
                    at android.app.ActivityThread.access$900(ActivityThread.java:161) 
                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265) 
                    at android.os.Handler.dispatchMessage(Handler.java:102) 
                    at android.os.Looper.loop(Looper.java:157) 
                    at android.app.ActivityThread.main(ActivityThread.java:5356) 
                    at java.lang.reflect.Method.invokeNative(Native Method) 
                    at java.lang.reflect.Method.invoke(Method.java:515) 
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265) 
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081) 
                    at dalvik.system.NativeStart.main(Native Method) 
  </code></pre>
  
  <p>I/Process: Sending signal. PID: 7818 SIG: 9
  Application terminated.</p>
  
  <p>this is xmlFile</p>
  
  <pre><code>&lt;LinearLayout 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"
  android:orientation="vertical"
  android:background="@color/AppColor"
  tools:context="com.example.vickyy.iwasframed.FrameActivity"&gt;
  
  &lt;android.support.v7.widget.Toolbar
      android:layout_width="match_parent"
      android:layout_height="40dp"
      android:id="@+id/toolbar"
      android:background="@color/ActionBarColor"&gt;
  
  
      &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@color/ActionBarColor"&gt;
  
  
          &lt;Button
              android:id="@+id/btnDone"
              android:layout_width="45dp"
              android:layout_height="30dp"
              android:text="Done"
              android:layout_centerVertical="true"
              android:textColor="@android:color/white"
              android:backgroundTint="@color/ButtonColor"
              android:layout_alignParentLeft="true"
              android:textSize="8sp"/&gt;
  
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="USE IMAGE SIZE"
              android:textColor="@android:color/white"
              android:layout_centerHorizontal="true"
              android:layout_centerVertical="true"
              android:textStyle="bold"
              android:textSize="16sp"/&gt;
  
  
      &lt;/RelativeLayout&gt;
  
  
  &lt;/android.support.v7.widget.Toolbar&gt;
  &lt;RelativeLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      &gt;
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:weightSum="3"
          android:orientation="horizontal"
          android:layout_marginLeft="10dp"
          android:layout_marginTop="10dp"
          android:layout_marginRight="10dp"&gt;
          &lt;TextView
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:text="WIDTH:"
              android:layout_weight="1"/&gt;
  
          &lt;TextView
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:text="HEIGHT:"
              android:layout_weight="1"
              android:layout_marginLeft="10dp"/&gt;
  
          &lt;TextView
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:text="MAT OVERLAP:"
              android:layout_weight="1"
              android:layout_marginLeft="10dp"/&gt;
  
  
  
  
      &lt;/LinearLayout&gt;
  
  &lt;/RelativeLayout&gt;
  
  &lt;RelativeLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginLeft="10dp"
      android:layout_marginTop="0dp"
      android:layout_marginRight="10dp"&gt;
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:weightSum="3"
          android:orientation="horizontal"&gt;
      &lt;EditText
          android:layout_weight="1"
          android:id="@+id/edtWidth"
          android:layout_width="match_parent"
          android:layout_height="25dp"
          android:paddingLeft="10dp"
          android:layout_toLeftOf="@+id/txtX"
          android:textSize="10sp"
  
          android:textStyle="bold"
          android:textCursorDrawable="@null"
          android:background="@drawable/custom_edittext"
          android:inputType="numberDecimal"
          android:layout_marginRight="10dp"&gt;
  
      &lt;/EditText&gt;
  
  
  
  
  
      &lt;EditText
          android:layout_weight="1"
          android:id="@+id/edtHeight"
          android:layout_width="match_parent"
          android:layout_height="25dp"
          android:layout_toRightOf="@+id/txtX"
          android:textCursorDrawable="@null"
          android:layout_marginLeft="10dp"
          android:textSize="10sp"
          android:paddingLeft="10dp"
  
          android:textStyle="bold"
          android:inputType="numberDecimal"
          android:background="@drawable/custom_edittext"
          android:layout_alignParentRight="true"&gt;
  
      &lt;/EditText&gt;
  
          &lt;EditText
              android:layout_weight="1"
              android:id="@+id/edtOverlap"
              android:layout_width="match_parent"
              android:layout_height="25dp"
              android:layout_toRightOf="@+id/txtX"
              android:textCursorDrawable="@null"
              android:layout_marginLeft="10dp"
              android:textSize="10sp"
              android:paddingLeft="10dp"
  
              android:textStyle="bold"
              android:inputType="numberDecimal"
              android:background="@drawable/custom_edittext"
              android:layout_alignParentRight="true"&gt;&lt;/EditText&gt;
  
      &lt;/LinearLayout&gt;
  
  &lt;/RelativeLayout&gt;
  
  
  
  &lt;FrameLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
  
      android:id="@+id/frameLayout"&gt;
  
      &lt;com.example.vickyy.iwasframed.CustomFrame
          android:id="@+id/imgFrame"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  
      &lt;ImageView
          android:id="@+id/imgView"
          android:layout_width="255dp"
          android:layout_height="360dp"
          android:scaleType="fitXY"
          android:layout_gravity="center"
          android:src="@drawable/flower"
          /&gt;
  
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>and this is the custom class that i code for draw rectangle with double and triple Mat</p>
  
  <pre><code>public class CustomFrame extends AppCompatImageView{
  
  
  Paint paint;
  int top,left,right,bottom;
  Context context;
  public CustomFrame(Context context) {
      super(context);
      paint = new Paint();
      this.context=context;
  }
  
  CustomFrame(Context context, AttributeSet attrs) {
      super(context, attrs);
  }
  
  CustomFrame(Context context, AttributeSet attrs, int defStyle) {
      super(context, attrs, defStyle);
  }
  
  @Override
  public void onDraw(Canvas canvas) {
      super.onDraw(canvas);
      SharedPreferences sharedPreferences = getContext().getSharedPreferences("Params", Context.MODE_PRIVATE);
      int color = sharedPreferences.getInt("color",R.color.black);
      int canvasW = getWidth();
      int canvasH = getHeight();
      Point centerOfCanvas = new Point(canvasW / 2, canvasH / 2);
      int width = sharedPreferences.getInt("width",0);
      int height = sharedPreferences.getInt("height",0);
      int overLap=sharedPreferences.getInt("OverLap",0);
      boolean start=sharedPreferences.getBoolean("start",false);
  
  
      int rectW = width*75;  //convert to pixel
      int rectH = height*75;
      left = centerOfCanvas.x - (rectW / 2);
      top = centerOfCanvas.y - (rectH / 2);
      right = centerOfCanvas.x + (rectW / 2);
      bottom = centerOfCanvas.y + (rectH / 2);
      paint = new Paint();
      paint.setColor(color);
      paint.setStyle(Paint.Style.STROKE);
  /*    if(start) {
          paint.setStrokeWidth(20);
      }
      else{
  
      }*/
      paint.setStrokeWidth(overLap);
      int l,t,r,b;
      int tripleLeft,tripleTop,tripleRight,tripleBottom;
  
  
  
      boolean doubleMat = sharedPreferences.getBoolean("DoubleMat",false);
      boolean tripleMat = sharedPreferences.getBoolean("TripleMat",false);
  
      if(doubleMat){
          int matHeight = sharedPreferences.getInt("MatHeight",0);
          int matWidth = sharedPreferences.getInt("MatWidth",0);
          int thickness=sharedPreferences.getInt("Doublethickness",0);
          int matW = (width)*75;
          int matH = (height)*75;
          int matw=matW-overLap;
          int math=matH-overLap;
           l = centerOfCanvas.x - (matw / 2);
           t = centerOfCanvas.y - (math / 2);
           r = centerOfCanvas.x + (matw / 2);
           b = centerOfCanvas.y + (math / 2);
          Paint paint1 = new Paint();
          paint1.setColor(color);
          paint1.setStyle(Paint.Style.STROKE);
  
          paint1.setStrokeWidth(thickness);      //inside
  
          paint.setStrokeWidth(overLap);  //mat
  
          SharedPreferences.Editor editor = sharedPreferences.edit();
          editor.putInt("MatHeight",math);
          editor.putInt("MatWidth",matw);
          editor.commit();
  
          canvas.drawRect(left, top, right, bottom, paint);
          canvas.drawRect(l, t, r, b, paint1);
  
      }
      else if(tripleMat){
          int matHeight = sharedPreferences.getInt("MatHeight",0);
          int matWidth = sharedPreferences.getInt("MatWidth",0);
          int dThickness=sharedPreferences.getInt("Doublethickness",0);
          int tThickness=sharedPreferences.getInt("Triplethickness",0);
  
          int matW = (width)*75;  //-2 here
          int matH = (height)*75;
  
          int matw=matW-overLap;
          int math=matH-overLap;
  
          l = centerOfCanvas.x - (matw / 2);
          t = centerOfCanvas.y - (math / 2);
          r = centerOfCanvas.x + (matw / 2);
          b = centerOfCanvas.y + (math / 2);  //inside
  
          int tripleWidth=(width)*75;
          int tripleHeight=(height)*75;
  
          int tmatw=tripleWidth-dThickness-overLap;
          int tmath=tripleHeight-dThickness-overLap;
  
          tripleLeft=centerOfCanvas.x-(tmatw/2);
          tripleTop=centerOfCanvas.y-(tmath/2);
          tripleRight=centerOfCanvas.x+(tmatw/2);
          tripleBottom=centerOfCanvas.y+(tmath/2);
  
          Paint triplePaint=new Paint();
          triplePaint.setColor(color);
          triplePaint.setStyle(Paint.Style.STROKE);
  
          triplePaint.setStrokeWidth(overLap);
  
          Paint paint1 = new Paint();
          paint1.setColor(color);
          paint1.setStyle(Paint.Style.STROKE);
  
  
          paint1.setStrokeWidth(dThickness);      //inside
          paint.setStrokeWidth((int)tThickness);  //mat
  
          SharedPreferences.Editor editor = sharedPreferences.edit();
          editor.putInt("MatHeight",tmath);
          editor.putInt("MatWidth",tmatw);
          editor.commit();
  
          canvas.drawRect(left, top, right, bottom, triplePaint); //outer
          canvas.drawRect(l, t, r, b, paint1);  //inside
         canvas.drawRect(tripleLeft,tripleTop,tripleRight,tripleBottom,paint); //outside
  
      }
      else {
  
     /*     Rect r=new Rect(left,top,right,bottom);
          //left
          canvas.drawLine(r.left,r.top,r.left,r.bottom,paint);
          //top
          canvas.drawLine(r.left,r.top,r.right,r.top,paint2);
          //right
          canvas.drawLine(r.right,r.top,r.right,r.bottom,paint);
          //bottom
          canvas.drawLine(r.left,r.bottom,r.right,r.bottom,paint2);*/
  
         // canvas.drawLine();
         // String text=String.valueOf(overLap);
         canvas.drawRect(left, top, right, bottom, paint);
      //   canvas.drawText(text,left,bottom,paint);
       }
  
     }
  
   }
  </code></pre>