I need to know how to move a image from one location to another location smoothly. In some tutorials they have asked to move it pixel by pixel calling invalidate() function after waiting for a small time duration.
But isnt there any other way to do it.?
But i need to开发者_JAVA技巧 animate it dynamically. Think that i need to move some image to the location where person touches on screen. I need it to be do using Java, not from XML
You can create a animation on XML, load it and use on your view.
Consider it's the file hide.xml (on the res/anim folder)
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="0" android:toYDelta="100"
android:duration="300" android:fillAfter="true" />
Then in your Activity you load it and apply to the View you want to translate.
Animation hide = AnimationUtils.loadAnimation(this, R.anim.hide);
yourView.startAnimation(hide);
精彩评论