2010-05-21 62 views

回答

4

覆盖draw()而不是onDraw()来旋转背景。

@Override 
public void draw(Canvas canvas) { 
    canvas.save(); 
    canvas.rotate(45,xRotation,yRotation); 
    super.draw(canvas); 
    canvas.restore(); 
} 
+0

Thx!有没有办法在这个旋转上启用抗锯齿? – Goo 2013-02-26 19:25:45

2
public class MainActivity extends Activity 
{ 
    private ImageView mImageView = null; 
    private Animation mRotateAnimation = null; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     mImageView = (ImageView) findViewById(R.id.my_image); 
     mRotateAnimation = AnimationUtils.loadAnimation(this, R.anim.my_rotate_90); 
    } 

    @Override 
    public boolean onTouchEvent(MotionEvent event) { 
     if (event.getAction() == MotionEvent.ACTION_DOWN) { 
      mImageView.startAnimation(mRotateAnimation); 
      return true; 
     } 
     return super.onTouchEvent(event); 
    } 
} 
+0

这应该被标记为正确的。 – Warpzit 2012-06-04 11:37:29