Android PorterDuff模式,用于从一个可牵引到另一个的衰减?

Android PorterDuff模式,用于从一个可牵引到另一个的衰减?,android,animation,bitmap,imageview,porter-duff,Android,Animation,Bitmap,Imageview,Porter Duff,我想把左下方的图片改成右边的图片,在右边的图片上加上另一个,使它看起来像是块基本上正在淡入 要做到这一点,我相信我可以使用PorterDuff方法和一些动画,但我不知道如何动画它 我编写了以下代码,使用PorterDuff并尝试添加一些动画,但它不会在更改时设置动画。如何实现这一目标,有什么建议吗 int oldId = getResources().getIdentifier("rainguage_" + (count-1), "drawable",

我想把左下方的图片改成右边的图片,在右边的图片上加上另一个,使它看起来像是块基本上正在淡入

要做到这一点,我相信我可以使用PorterDuff方法和一些动画,但我不知道如何动画它

我编写了以下代码,使用PorterDuff并尝试添加一些动画,但它不会在更改时设置动画。如何实现这一目标,有什么建议吗

int oldId = getResources().getIdentifier("rainguage_" + (count-1), "drawable", getApplicationContext().getPackageName());
int newId = getResources().getIdentifier("rainguage_" + count, "drawable", getApplicationContext().getPackageName());
Bitmap bit1 = BitmapFactory.decodeResource(getResources(), oldId);
Bitmap bit2 = BitmapFactory.decodeResource(getResources(), newId);
Bitmap drawingBitmap = Bitmap.createBitmap(bit1.getWidth(), bit1.getHeight(), bit1.getConfig());
canvas = new Canvas(drawingBitmap);
paint = new Paint();
canvas.drawBitmap(bit1, 0,0, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_ATOP));

Animation anim = new AlphaAnimation(0.0f, 1.0f);
anim.setDuration(1000);
anim.setInterpolator(new LinearInterpolator());
imageView.setAnimation(anim);

canvas.drawBitmap(bit2, 0,0, paint);
imageView.setImageBitmap(drawingBitmap);