How to rotate floating action button without rotating shadow?

后端 未结 4 1767
一个人的身影
一个人的身影 2021-01-02 01:26

I rotate the FAB in such a simple way:

fab.startAnimation(AnimationUtils.loadAnimation(this, R.anim.rotate));

rotate.xml:

4条回答
  •  悲哀的现实
    2021-01-02 01:50

    public void rotateFabForward() {
        ViewCompat.animate(fab)
                .rotation(135.0F)
                .withLayer()
                .setDuration(300L)
                .setInterpolator(new OvershootInterpolator(10.0F))
                .start();
    }
    
    public void rotateFabBackward() {
        ViewCompat.animate(fab)
                .rotation(0.0F)
                .withLayer()
                .setDuration(300L)
                .setInterpolator(new OvershootInterpolator(10.0F))
                .start();
    }
    

提交回复
热议问题