How to make whatsapp type of animation for opening the menu from toolbar(actionbar)

前端 未结 4 967
难免孤独
难免孤独 2020-12-25 11:38

Description:

  1. I recently updated whatsapp and noticed the animation for menu item clicked on toolbar. How to achieve this effect?
  2. Are there any opens
4条回答
  •  死守一世寂寞
    2020-12-25 11:46

    Yes we can use the circular reveal effect now on 2.3+

    We can achieve this effect by using this Circular Reveal Library.

    adding the library dependency

     dependencies {
            compile ('com.github.ozodrukh:CircularReveal:1.3.1@aar') {
                transitive = true;
            }
        }
    

    Use regular RevealFrameLayout & RevealLinearLayout don't worry, only target will be clipped :)

    
    
        
    
        
    
    
    

    and in code add

     View myView = findView(R.id.awesome_card);
    
        // get the center for the clipping circle
        int cx = (myView.getLeft() + myView.getRight()) / 2;
        int cy = (myView.getTop() + myView.getBottom()) / 2;
    
        // get the final radius for the clipping circle
        int dx = Math.max(cx, myView.getWidth() - cx);
        int dy = Math.max(cy, myView.getHeight() - cy);
        float finalRadius = (float) Math.hypot(dx, dy);
    
        SupportAnimator animator =
                ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius);
        animator.setInterpolator(new AccelerateDecelerateInterpolator());
        animator.setDuration(1500);
        animator.start();
    

提交回复
热议问题