为什么显示效果不工作按开发者博客(Why Reveal effect not working as

2019-10-22 06:30发布

I want to have Reveal Effect with in my app. I come to know about it for how it can be implemented. I got the information from the Andoid Developer Blog.

But when i have updated that with in my code, it is not showing any effect.

I have also try with Demo given by Google to demostrate Reveal effect. But it also not showing the effect. If there any permission i need to add or whats wrong i am doing?

My animator is as below:

View button = rootView.findViewById(R.id.button);
    final View shape = rootView.findViewById(R.id.circle);
    shape.setClipToOutline(false);
    shape.setVisibility(View.INVISIBLE);
    // Set a listener to reveal the view when clicked.
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            if(isShowing==false){
                // previously invisible view

                // get the center for the clipping circle
                int cx = (shape.getLeft() + shape.getRight()) / 2;
                int cy = (shape.getTop() + shape.getBottom()) / 2;

                // get the final radius for the clipping circle
                int finalRadius = Math.max(shape.getWidth(), shape.getHeight());

                // create the animator for this view (the start radius is zero)
                Animator anim =
                        ViewAnimationUtils.createCircularReveal(shape, cx, cy, 0, finalRadius);

                // make the view visible and start the animation
                shape.setVisibility(View.VISIBLE);
                anim.setDuration(4000);
                anim.start();
            }else{

                // get the center for the clipping circle
                int cx = (shape.getLeft() + shape.getRight()) / 2;
                int cy = (shape.getTop() + shape.getBottom()) / 2;

                // get the initial radius for the clipping circle
                int initialRadius = shape.getWidth();

                // create the animation (the final radius is zero)
                Animator anim =
                        ViewAnimationUtils.createCircularReveal(shape, cx, cy, initialRadius, 0);

                // make the view invisible when the animation is done
                anim.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        super.onAnimationEnd(animation);
                        shape.setVisibility(View.INVISIBLE);
                    }
                });

                anim.setDuration(4000);
                // start the animation
                anim.start();
            }

            isShowing = !isShowing;

    }
    });

Please let me know how to achieve this effect.

Answer 1:

这是与棒棒堂推出并非一切都被回迁。 显示,纹波和高程是一些例子。 主要的原因是,他们中的一些严重依赖于新的UI Thread介绍丝毫ART 。 你可以找到更多的信息在这里 ,在最底层,在常见问题解答部分



文章来源: Why Reveal effect not working as per Developer blog