LayoutInflater inflater=LayoutInflater.from(context);
View view=inflater.inflate(R.layout.main, null);
TextView tv=(TextView)view.findViewById(R.id.mytextview);
tv.setText("gggggggggggg");
tv.setTextColor(Color.BLACK);Bitmap tmpBmp = Bitmap.createBitmap(400,600,Bitmap.Config.ARGB_8888); 
Canvas mCanvas = new Canvas(tmpBmp);
view.draw(mCanvas);
canvas.drawBitmap(tmpBmp,0, 0, null); 
可是画出来的是布局,里面的textview和别的控件都没有显示,怎么回事

解决方案 »

  1.   

    protected void onDraw(Canvas canvas) {
    // TODO Auto-generated method stub
    super.onDraw(canvas);
    /* Matrix mx=new Matrix();
    //mx.postRotate(arc, 5, 30);
    mx.postRotate(arc);
    Bitmap bitmap=BitmapFactory.decodeResource(getResources(), R.drawable.a);
    Bitmap bip=Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), mx, true);
    canvas.drawBitmap(bip,0, 0, null);
    arc++;*/
    LayoutInflater inflater=LayoutInflater.from(context);
    View view=inflater.inflate(R.layout.main, null);
    TextView tv=(TextView)view.findViewById(R.id.mytextview);
    tv.setText("gggggggggggg");
    tv.setTextColor(Color.BLACK);

    Bitmap tmpBmp = Bitmap.createBitmap(400,600,Bitmap.Config.ARGB_8888); 
    Canvas mCanvas = new Canvas(tmpBmp);
    view.draw(mCanvas);
    canvas.drawBitmap(tmpBmp,0, 0, null);    
    }