我在使用支持库 23 的 KitKat 设备上有一个 FAB。我正在缩放按钮以获得过渡效果(通过将其包含在调整大小的视图中)。这基本上与阴影不同,阴影以一种奇怪的形式出现(参见屏幕截图中缩放的红色按钮,蓝色按钮是全尺寸)。
实际发生的情况是,阴影位于 4 个“角”位图中,这些位图重叠以产生奇怪的效果。
有谁知道如何解决这个问题?
这看起来很有趣!
不幸的是,我没有成功地尝试重现该问题 - 如果您可以提供您运行的代码,那就太好了 - 但这是我编写的用于动画和缩放浮动操作按钮的代码,如下所示:
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();
当然,特定的动画速度和效果是可以调整和改进的。
我希望,它有帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)