I have an animation that moves a TextView from left to right when button is pressed. Now I want the endpoint become the new origin of next animation. Problem is that when i click button again, animation is reset and start from previous old startpoint.
anim1=new TranslateAnimation(Animation.RELATIVE_TO_SELF,0.0f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.0f,
Animation.RELATIVE_TO_SELF,0.0f);
anim1.setFillEnabled(true);
anim1.setFillAfter(true);
anim1.setInterpolator(new AnticipateInterpolator(2.5f));
anim1.setDuration(500);
btnStart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
textview1.startAnimation(anim1);
}
});
And this is my xml layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainAnimation" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/btnStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_alignRight="@+id/textView1"
android:layout_marginTop="22dp"
android:text="Start" />
</RelativeLayout>
An help is apprecciate. Thanks a lot.