title: How to add custom view to the layout?
body: <p>I have a <code>GraphicsView</code> class that extends from the <code>View</code> class and I want to add this <code>GraphicsView</code> class to the main layout in my project. How can I do that?</p>
  
  <pre><code>static public class GraphicsView extends View {
          public GraphicsView(Context context) {
          super(context);
          }
          @Override
          protected void onDraw(Canvas canvas) {
          // Drawing commands go here
              Path rect = new  Path();
              rect.addRect(100, 100, 250, 50, Direction.CW);
              Paint cPaint = new Paint();
              cPaint.setColor(Color.LTGRAY); 
              canvas.drawPath(rect, cPaint);
          }
      }
  </code></pre>
  
  <p>and my <code>main.xml</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/linnnnlayout"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical" &gt;
  
      &lt;TextView
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:text="@string/hello" /&gt;
  
      &lt;TextView 
          android:id="@+id/Customfont"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:text="@string/hello" /&gt;
  
       &lt;View 
           android:id="@+id/view"
            android:layout_width="fill_parent"
          android:layout_height="wrap_content"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>