如何使用支持库23修复缩放的FloatingActionButton上的阴影

chr*_*ris 5 android android-support-library material-design floating-action-button

我在使用支持库23的KitKat设备上有一个FAB.我正在缩放按钮以获得过渡效果(通过在调整大小视图中包含它).这基本上与阴影区分开来,阴影以奇怪的形式出现(参见屏幕截图中的缩放红色按钮,蓝色按钮是全尺寸).

在此输入图像描述

实际上似乎发生的是阴影位于4个"角落"位图中,这些位图重叠以产生奇怪的效果.

有谁知道如何解决这个问题?

Kon*_*nov 0

这看起来很有趣!

不幸的是,我没有成功地尝试重现该问题 - 如果您可以提供您运行的代码,那就太好了 - 但这是我为动画和缩放浮动操作按钮编写的代码,如下所示:

在此输入图像描述

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.animate().scaleX(0.1f).scaleY(0.1f).setDuration(100).setListener(
    new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animator) {}

        @Override
        public void onAnimationEnd(Animator animator) {
            fab.setBackgroundTintList(getResources().getColorStateList(R.color.colorPrimary, getTheme()));
            fab.setImageDrawable(getResources().getDrawable(R.drawable.common_full_open_on_phone, getTheme()));

            fab.animate().scaleX(2).scaleY(2).setListener(null).setDuration(200).start();
        }

        @Override
        public void onAnimationCancel(Animator animator) {}

        @Override
        public void onAnimationRepeat(Animator animator) {}
    }).start();
Run Code Online (Sandbox Code Playgroud)

当然,特定的动画速度和效果是可以调整和改进的。我希望,它有帮助。