You can define a change in orientation by overriding onConfigurationChanged() as follows:
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig);
Then, as soon as you detect an orientation change event, you can perform an animated rotation on the button as follows:
public void rotateView(View view) { Button button = (Button) view.findViewById(R.id.some_button); RotateAnimation rotateAnimation = new RotateAnimation(0, 360); rotateAnimation.setDuration(2000); button.startAnimation(rotateAnimation); }
You can set the start and end angles in the RotateAnimation constructor, and then set the duration of the animation duration (in milliseconds). Then you just call startAnimation() on the view you want to animate.
source share