title: How to draw something on Android layout?
body: <p>This is the activity</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
          fab.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                          .setAction("Action", null).show();
              }
          });
      }
  
  }
  </code></pre>
  
  <p>I know I can create a class</p>
  
  <pre><code>public class DrawView extends View {
      Paint paint = new Paint();
  
      public DrawView(Context context) {
          super(context);
          paint.setColor(Color.BLACK);
      }
  
      @Override
      public void onDraw(Canvas canvas) {
          canvas.drawLine(0, 0, 20, 20, paint);
          canvas.drawLine(20, 0, 0, 20, paint);
      }
  }
  </code></pre>
  
  <p>And use it in activity</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      drawView = new DrawView(this);
      drawView.setBackgroundColor(Color.WHITE);
      setContentView(drawView);
  
  }
  </code></pre>
  
  <p>But it must replace my original layout <code>setContentView(R.layout.activity_main);</code></p>
  
  <p>If I use layout, I cannot draw something, if I draw something, I cannot use layout</p>
  
  <p>How can I keep both?</p>