`
wang_peng1
  • 浏览: 3904062 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

简单旋转

 
阅读更多

@Override
public void onDraw(Canvas canvas) {
    //This saves off the matrix that the canvas applies to draws, so it can be restored later. 
    canvas.save(); 

    //now we change the matrix
    //We need to rotate around the center of our text
    //Otherwise it rotates around the origin, and that's bad. 
    float py = this.getHeight()/2.0f;
    float px = this.getWidth()/2.0f;
    canvas.rotate(180, px, py); 

    //draw the text with the matrix applied. 
    super.onDraw(canvas); 

    //restore the old matrix. 
    canvas.restore(); 
}
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics