@Override
    public void draw(Canvas canvas) {
        if (mDrawable!=null) {
            int sc=canvas.save();
            if (mAnimation!=null) {
                mAnimation.getTransformation(
                                         AnimationUtils.currentAnimationTimeMillis(),
                                         mTransformation);
                canvas.concat(mTransformation.getMatrix());
            }
            mDrawable.draw(canvas);
            canvas.restoreToCount(sc);
        }
    }

canvas.save()和canvas.restoreToCount(sc);是用来保存和回复Canvas的状态(Maxtrix等属性),因为我们需要修改Canvas的Matrix属性,canvas.concat方法都会和当前Canvas的Matrix进行矩阵运算,如果我们不保存之前的Matrix属性,每次都会跟上次矩阵运算的结果相乘,对应本例来说,每次平移的距离会越来越大。

 

转:http://blog.csdn.net/gaomatrix/article/details/6525240

相关文章:

  • 2021-08-29
  • 2022-12-23
  • 2022-12-23
  • 2021-05-26
  • 2021-10-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-28
  • 2022-12-23
  • 2021-08-01
  • 2022-12-23
相关资源
相似解决方案