1

我想在我的应用程序中显示效果。我开始了解它是如何实施的。我从Andoid 开发者博客中获得了信息。

但是当我在我的代码中更新它时,它没有显示任何效果。

我还尝试使用Google 提供的 Demo来演示 Reveal 效果。但它也没有显示效果。如果我需要添加任何许可或我在做什么错?

我的动画师如下:

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;

    }
    });

请让我知道如何实现此效果。

4

1 回答 1

0

并非所有与 Lollipop 一起引入的东西都被反向移植。显示、波纹和海拔是一​​些例子。主要原因是其中一些严重依赖新UI Thread引入的whit ART你可以在这里找到更多信息,在最底部的常见问题解答部分

于 2015-07-01T08:49:18.817 回答