Reputation: 570
I'm trying to rotate
Floating Action Button
, but I can see whether very fast animation or nothing.
Here's res/anim/rotate.xml
<?xml version="1.0" encoding="UTF-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1600"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:fillAfter="true"
android:toDegrees="180" />
After the testing it with simple TextView
I've found, that it worked.
And this is how I try to start animation.
final Animation rotate = AnimationUtils.loadAnimation(MainActivity.this, R.anim.rotate);
final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
fab.startAnimation(rotate);
}
});
All what can I see is standard onClick
animation of the FAB
(or very fast animation, if I use scale one)
What can I do with it?
Upvotes: 0
Views: 560
Reputation: 348
Declaring the animation from code helped me. Try something like this:
ViewCompat.animate(fab).rotation(180).setDuration(1600).start();
It seems that the clicked FAB has another animation to proceed and it overrides your animation.
Upvotes: 1