Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android位图转换动画_Android_Android Animation - Fatal编程技术网

android位图转换动画

android位图转换动画,android,android-animation,Android,Android Animation,我正在开发一个双陆棋游戏。我用canvas.drawBitmap绘制棋盘和棋子。我想使用动画将片段从一个位置移动到另一个位置。我该怎么做?我想我应该做一些翻译动画。我可以用位图来做吗? 谢谢。请检查此代码以设置ImageView的动画: final ImageView btnTranslate1 = (ImageView) findViewById(R.id.translate1); Animation translateAnimation1 = new TranslateAnimation(0

我正在开发一个双陆棋游戏。我用canvas.drawBitmap绘制棋盘和棋子。我想使用动画将片段从一个位置移动到另一个位置。我该怎么做?我想我应该做一些翻译动画。我可以用位图来做吗?
谢谢。

请检查此代码以设置ImageView的动画:

final ImageView btnTranslate1 = (ImageView) findViewById(R.id.translate1);
Animation translateAnimation1 = new TranslateAnimation(0f, x, 0f, y);
translateAnimation1.setDuration(500);
translateAnimation1.setInterpolator(new CircInterpolator(Type.INOUT));

// start your animation with this line
btnTranslate1.startAnimation(translate1);

为工件创建全局位置坐标,并使用更新

这里,插值时间将从0到1变化(*不完全取决于插值器)

根据动画的持续时间和插值器

mAnimation = new CustomAnimation();
mAnimation.setDuration(mDuration);
mAnimation.setInterpolator(mInterpolator);
startAnimation(mAnimation);

谢谢你的回复,但我不使用ImageView。正如我在问题中所说,我直接在画布上绘制位图。谢谢。我会试试看,但位图的动画制作真的不能再简单了吗?除了启动一个连续的过程并更新其中的属性外,没有办法在视图中设置任何元素的动画。(但可以使用属性animator设置视图动画)。
mAnimation = new CustomAnimation();
mAnimation.setDuration(mDuration);
mAnimation.setInterpolator(mInterpolator);
startAnimation(mAnimation);