我正在尝试使用Runnable
and为 ImageView 设置动画Handler.postDelayed
。位图操作都可以正常工作,但我得到的是 ImageView 的最终结果,而不是动画。这里有什么问题?
final ImageView imageView = (ImageView) findViewById(R.id.imageView);
final Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.clock_flip_top);
final Matrix matrix = new Matrix();
for (i = 0; i < 30; i++) {
float c = i/5;
src = new float[] { 0, 0, bitmap.getWidth(), 0,
bitmap.getWidth(), bitmap.getHeight(), 0,
bitmap.getHeight() };
dst = new float[] { 0 - c, 0, bitmap.getWidth() + c, 0,
bitmap.getWidth(), bitmap.getHeight(), 0,
bitmap.getHeight() };
anim = new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
matrix.setPolyToPoly(src, 0, dst, 0, src.length >> 1);
Bitmap newBitmap = Bitmap
.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
bitmap.getHeight(), matrix, true);
imageView.setImageBitmap(newBitmap);
handler.postDelayed(anim, i * 200);
}
};
anim.run();
}