当我对画布对象使用旋转方法时,画布对象不会旋转。为什么会这样?这是我的代码
package com.example.hello;
import android.app.Activity; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.os.Bundle; import android.view.View; import android.widget.LinearLayout;
public class CanvasDrawExample extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.example);
LinearLayout rl=(LinearLayout)findViewById(R.id.rl);
rl.addView(new CircleView(this));
}
public class CircleView extends View
{
public CircleView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
Paint p=new Paint(Paint.ANTI_ALIAS_FLAG);
p.setStrokeWidth(100);
p.setStyle(Paint.Style.STROKE);
p.setColor(Color.BLUE);
canvas.drawRect(200, 100, 200, 100, p);
canvas.save();
canvas.rotate((float)145);
canvas.restore();
}
}
}