Reputation: 3270
As the title suggests, I would like to know programmatically if a given View has been rotated already. Here is my animation function:
public static void AnimateArrowDown(View v)
{
RotateAnimation anim = new RotateAnimation(0.0f, 90.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
anim.setInterpolator(new LinearInterpolator());
anim.setDuration(200);
anim.setFillAfter(true);
v.findViewById(R.id.arrow_imageview).startAnimation(anim);
}
I'm animating an arrow right to down inside a ListView. My problem is when the view is redraw for some list elements the arrow previously rotated for another list item gets passed to this new list item. Hence, I would like to determine if the arrow in the ListView has been rotated and if so then rotate the arrow to its actual position.
Upvotes: 1
Views: 65
Reputation: 12478
You can use View.getRotation
method.
float rotation = v.findViewById(R.id.arrow_imageview).getRotation();
Then you can determine the value is default (0.0f
; not rotated) or not (90.0f
; rotated).
(Note: However, I would also prefer another approach using state flags like Saehun Sean Oh mentions in his comment. I don't think they need to be static but to be field members, and keep boolean states there.)
Upvotes: 2