then you can try changing the second animation with the animation in xml and gates ObjectAnimator in the onClick method. example:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button prova1 = (Button)findViewById(R.id.prova);
final Animation trans = AnimationUtils.loadAnimation(this, R.anim.trans);
ObjectAnimator mover = ObjectAnimator.ofFloat(prova1, "translationY", 0, 1000);
mover.setDuration(2000);
mover.start();
prova1.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
mover.cancel();
prova1.startAnimation(trans);
}});
}
}
create xml code in your res->anim->trans :
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<translate
android:fromYDelta="0"
android:toYDelta="2000"
android:duration="20000"
/>
</set>