如何使用支持库23固定在缩放FloatingActionButton阴影 [英] How to fix shadow on scaled FloatingActionButton using support library 23

查看:361
本文介绍了如何使用支持库23固定在缩放FloatingActionButton阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用支持库23.我缩放的过渡效果的按钮(含在一个大小调整视图)一个奇巧设备上的FAB。这基本上从影子,它出现在一个奇怪的形式分开工作(见截图缩放红色按钮,蓝色按钮是全尺寸)。

I have a FAB on a KitKat device using support library 23. I'm scaling the button for a transition effect (by containing it in a resizing view). This basically works apart from the shadow, which appears in a weird form (see the scaled red button in the screenshot, the blue button is full size).

在这里输入的形象描述

其实什么似乎发生的是,阴影是重叠产生一个奇怪的效应4角位图。

What actually appears to happen is that the shadow is in 4 "corner" bitmaps that overlap to produce an odd effect.

有谁知道这可怎么固定?

Does anyone know how this can be fixed?

推荐答案

这看起来很有趣!

不幸的是,我没有成功尝试重现的问题 - 它会是不错的,如果你能提供您运行code - 但这里的code我写的动画和放大器;大规模浮动的行动按钮是这样的:

Unfortunately, I didn't succeed trying to reproduce the issue on - it'd be nice, if you can provide the code you run - but here's the code I wrote to animate&scale floating action button like this:

在这里输入的形象描述

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();

当然,尤其是动画速度和效果,可以调整和改善。
我希望,它帮助。

Of course, particular animation speed and effects can be adjusted and improved. I hope, it helps.

这篇关于如何使用支持库23固定在缩放FloatingActionButton阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆