1

I have rotation animation that starts vertically and ends horizontally (90 degrees).
I need to make the animation stay horizontally until some button is pressed, but it just keeps going back to its vertical state

Click listeners:

holder.options.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                holder.options.startAnimation(AnimationUtils.loadAnimation(context,R.anim.rotate_right));
                setMenuOptionsButton();
            }}

The animation

<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
    android:fromDegrees="0"
    android:toDegrees="90"
    android:pivotX="50%"
    android:pivotY="50%"
    android:duration = "500"
    android:fillAfter="true"
    android:interpolator="@android:anim/linear_interpolator"
    />

I saw some solutions here and it didn't help me

Tamir Abutbul
  • 7,301
  • 7
  • 25
  • 53

1 Answers1

1

Try this:

Animation anim = AnimationUtils.loadAnimation(context,R.anim.rotate_right);
anim.setAnimationListener(new Animation.AnimationListener() {
    @Override
    public void onAnimationStart(Animation animation) {

    }

    @Override
    public void onAnimationEnd(Animation animation) {
        holder.options.setRotation(90);
    }

    @Override
    public void onAnimationRepeat(Animation animation) {

    }
});

holder.options.startAnimation(anim);
nupadhyaya
  • 1,909
  • 1
  • 14
  • 14