// 建立遮罩效果动画 private void drawClip(Canvas canvas) { // 动画完成时,把整张图片显示出来 if (isStop3) { canvas.drawBitmap(bitmap, 0, 0, null); return; } // 当进行到当完成,将动画停止,但别忘了把背景图片显示出来 if (steep30 >= viewW && viewW != 0) { steep30 = 0; steep31 = 0; isStop3 = true; canvas.drawBitmap(bitmap, 0, 0, null); return; } // 20开始 for (int i = 0; i <= viewH; i = i + 40) { // 创建从左到右的遮罩动画 clip(canvas, bitmap, steep30, 20, 0, i); // 创建从右到左的遮罩动画 clip(canvas, bitmap, steep31, 20, viewW - steep31, i + 20); } // 运行一次遮罩动画前进行距离 steep30 += 5; steep31 += 5; } //进行图片裁剪 private void clip(Canvas canvas, Bitmap bit, int w, int h, int posX, int posY) { canvas.save(); canvas.clipRect(posX, posY, posX + w, posY + h); canvas.drawBitmap(bit, 0, 0, null); canvas.restore(); }
标签:提示信息,android,canvas