如何拖动屏幕按钮,给从当前位置到原来的位置翻译动画? [英] How to drag button on screen and give translate animation from current position to original position?

查看:206
本文介绍了如何拖动屏幕按钮,给从当前位置到原来的位置翻译动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要翻译的动画按钮执行。以下按钮是能拖布局。我拖动画面的任何地方的按钮,当我删除我的触摸,我要执行从按钮的电流下降能够变换点动画原来的地方这是最初按键位于屏幕上。如果任何一个有想法,然后来好

I want to translate animation perform on button. Here Buttons are drag able in layout. I drag the button on any place of screen and when I remove my touch,I want to perform transform animation from current drop able points of button to original place which is initially button located on the screen. if any one have idea then well come.

推荐答案

您可以用的查看得很干脆://开发商。 android.com/guide/topics/graphics/prop-animation.html相对=nofollow> 查看物业动画>是这样的:

You can animate any View very simply with a View Property Animator like this:

button.animate().translationX(deltaX)
                .translationY(deltaY)
                .setDuration(duration);

这适用于API级别11以上。如果假定API级别工作前11,那么你需要使用 <强>查看动画

This works on API level 11 and above. If it is supposed to work before API level 11 then you need to use View Animations:

TranslateAnimation animation = new TranslateAnimation(fromX, toX, fromY, toY);
animation.setDuration(duration);
button.startAnimation(animation);

如果您有任何进一步的问题随时问。

If you have any further question feel free to ask.

这篇关于如何拖动屏幕按钮,给从当前位置到原来的位置翻译动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆