title: Android canvas fill background color (Canvas application)
body: <p>By having the following codes, I have some questions.</p>
  
  <pre><code>public class MainActivity extends Activity {
  
     @Override
     public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView( new View(this) {
           Paint mPaint = new Paint();
  
           @Override
           protected void onDraw(Canvas canvas) {
              // TODO Auto-generated method stub
              super.onDraw(canvas);
  
  
              int width = this.getWidth();
              int height = this.getHeight();
              int radius = width &gt; height ? height/2 : width/2;
              int center_x = width/2;
              int center_y = height/2;
  
              // prepare a paint
              mPaint.setStyle(Paint.Style.STROKE);
              mPaint.setStrokeWidth(5);
              mPaint.setAntiAlias(true);
  
              // draw a rectangle
              mPaint.setColor(Color.BLUE);
                  mPaint.setStyle(Paint.Style.FILL); //fill the background with blue color
              canvas.drawRect(center_x - radius, center_y - radius, center_x + radius, center_y + radius, mPaint);
              // draw some text and rotation
              mPaint.setTextSize(50);
              mPaint.setTextAlign(Paint.Align.CENTER);
              mPaint.setColor(Color.BLACK);
              canvas.drawText( "Hello World" , center_x , center_y, mPaint);
           }
        });
      }
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/Bx3NU.png" alt="enter image description here"></p>
  
  <p>Q1: How can I fill blue colour in the frame? (The words still appear)</p>
  
  <p>Q2: How many views and surfaces in this app? How can I count these in the app?</p>
  
  <p>Q3: How many windows in this app?</p>
  
  <p>Q4: In the code, I dont see any bitmap object in it. 
      However, I thought that bitmap is the object that I can really draw things on it. Is my
      understanding incorrect? 
      One possibility is that Canvas constructor initializes bitmap when it is newed. </p>
  
  <p>Q5: I knew that these graphic thing will finally go to surface and then pass to
      surfaceflinger for final composition. Where does it locate in my code?</p>
  
  <p>Thanks for any reply.</p>