android自定义控件(二)Canvas

一。重要方法

1.translate
2.scale
3.rotate

 

二。注意

1.明确顺序

canvas.rotate(45);
canvas.drawRect(new Rect(50, 50, 100, 100), paint);

如果顺序调换,则没有旋转的效果

 

2.转换的时候,需要把转换的中心点移到shape自身的中心

int left=50,top=50, right = 100,bottom = 100;
canvas.translate(right/2, bottom/2);
canvas.rotate(45);
canvas.drawRect(new Rect(-right/2, -bottom/2, right/2, bottom/2), paint);

 

3.变换过程

 

 

posted @ 2014-06-06 14:48  等风来。。  Views(235)  Comments(0Edit  收藏  举报
------------------------------------------------------------------------------------------------------------ --------------- 欢迎联系 x.guan.ling@gmail.com--------------- ------------------------------------------------------------------------------------------------------------