The canvas which created in onCreate is not the canvas which the activity draw on.If you want draw the activity, you should draw it in View.onDraw or ViewGroup.dispatchDraw.
It means you should create a new class which extends ViewGroup or View.

解决方案 »

  1.   

    只能继承view和 viewgroup来重写吗?
      

  2.   

    你的代码是显示  R.layout.main
      

  3.   

    在main里面画不了? 那要怎样才能在屏幕上任意画图呢?
      

  4.   

    必须写一个新的类继承自 View 或者 View Group,在Activity类中实例化该类,并在setContentView()中显示你的View类,必须在View类中的onDraw()中绘图,如1楼所说