首页 > 解决方案 > 在运行时添加模糊效果

问题描述

我尝试使用动画将图像从一个位置移动到另一个位置。这是我的代码

 int[] locationTo = new int[2];
    secondView.getLocationOnScreen(locationTo);
    int x1 = locationTo[0];
    int y1 = locationTo[1];


    logo.post(() -> {
        float height = logo.getHeight();
        logo.animate()
                .x(x1)
                .y(y1 - (height * 2))
                .setDuration(5000)
                .setListener(new Animator.AnimatorListener() {
                    @Override
                    public void onAnimationStart(Animator animator) {

                    }

                    @Override
                    public void onAnimationEnd(Animator animator) {

                    }

                    @Override
                    public void onAnimationCancel(Animator animator) {

                    }

                    @Override
                    public void onAnimationRepeat(Animator animator) {

                    }
                })
                .start();
    });

这段代码运行完美。我有两个问题 1) 有什么方法可以检查视图的 x1 和 y1 运行时吗?2)在我的视图运行时添加模糊效果的任何方式或任何库?当视图开始移动时,我会增加模糊效果。谢谢

标签: androidandroid-layoutandroid-animationandroid-blur-effect

解决方案


推荐阅读