I am using FloatingActionButton and OnClick. I wanted to display PopupMenu and rotate the same FAB button with nice Animation (rotating 90 degree).
On click, it should animate itself :
I am able to display a PopupMenu on its OnClick method but i am not able to rotate FAB itself. In fact, I am able to animate all other FloatingActionButton around it but i tried non of the FloatingActionButton can animate itself OnClick method.
I also tried NOT using FloatingActionButton, but a Simple Button that can animate (rotate) itself..
public class FloatingButtonPanel extends Fragment {
//.... Other code...
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//.... Other code...
final FloatingActionButton butA = (FloatingActionButton) view.findViewById(R.id.fb_menu);
butA.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
rotateAnimation(v);
}
});
return view;
}
public static void rotateAnimation(View v){
// Create an animation instance
final Animation an = new RotateAnimation(0, 90, v.getWidth()/2, v.getHeight()/2);
an.setDuration(1000);
an.setFillAfter(true);
v.clearAnimation();
v.startAnimation(an);
}
}
Can anyone help ?


