Android动画:视图直接更改为结束位置
Android动画:视图直接更改为结束位置,android,animation,android-studio,objectanimator,Android,Animation,Android Studio,Objectanimator,我接到一个任务,为android平台制作一款类似《糖果粉碎传奇》和《流》的游戏。我尝试了一些关于事件监听器和动画的教程,它工作得很好,但我在设置ImageView动画以更改其位置时遇到了问题。 我想在两个ImageView之间切换位置,当我在ImageView上滑动时(candy crush gameplay),它的位置完全改变了,但问题是动画移动不起作用。当我滑动其中一个ImageView(例如右滑动)时,该ImageView与位于其旁边的ImageView一起改变了位置,但我看不到像播放ca
我接到一个任务,为android平台制作一款类似《糖果粉碎传奇》和《流》的游戏。我尝试了一些关于事件监听器和动画的教程,它工作得很好,但我在设置ImageView动画以更改其位置时遇到了问题。 我想在两个ImageView之间切换位置,当我在ImageView上滑动时(candy crush gameplay),它的位置完全改变了,但问题是动画移动不起作用。当我滑动其中一个ImageView(例如右滑动)时,该ImageView与位于其旁边的ImageView一起改变了位置,但我看不到像播放candy crush saga时那样的运动动画
我使用2 ObjectAnimator设置该ImageView的动画,并在该ImageView上触发滑动事件时一起播放。这是我的动画代码
final String name = "x";
ImageView target = (ImageView) findViewById(id[x-1][y-1]);
ImageView next = (ImageView) findViewById(id[x-1][y]);
ObjectAnimator aTarget = ObjectAnimator.ofFloat(target, name, target.getX(), (target.getX()+target.getWidth()));
aTarget.setDuration(1000);
aTarget.setInterpolator(new LinearInterpolator());
ObjectAnimator aNext = ObjectAnimator.ofFloat(next, name, next.getX(), (next.getX()-next.getWidth()));
aNext.setDuration(1000);
aNext.setInterpolator(new LinearInterpolator());
AnimatorSet moveset = new AnimatorSet();
moveset.playTogether(aTarget, aNext);
moveset.start();
我使用ID数组保存ImageView的ID,并使用“for”将触发刷卡事件的视图ID与ID数组中的列表ID进行比较,以便找到要移动的ImageView(目标)的位置,以及将使用choosen one更改位置的其他ImageView。
我不明白这些代码有什么问题,我从当我运行应用程序时,它工作得非常好,但是当我尝试将它实现到我的应用程序时,我遇到了这个问题
希望有人能帮助我,之前非常感谢。上面的代码对我来说非常适合。可能与项目设置、设备或代码中的其他内容有关。关于您的信息,我想说的太多了,它终于起作用了。。对不起,这个问题是我自己的错。。问题来自电话;s开发者设置,我忘了设置动画,所以我设置为关闭。。对于其他像我这样遇到问题的人,你们也应该检查你们的开发者设置,也许你们也会像我一样得到prolem谢谢